K.Rock
K.Rock

Reputation: 43

iOS swift vpn connecting immediately disconnected

I have used three methods but all get the same result

1.only use Network Extension to connect the VPN

2.use OpenAdapter Demo https://github.com/ss-abramchuk/OpenVPNAdapter

3.use tunnelKit Demo https://github.com/passepartoutvpn/tunnelkit/issues

and I had check my configuration many times ,the tunnel bundle id is correct

I just did a few steps

clone the project 2.change the App Groups and Keychain Sharing group App IDs and Tunnel extension id and use my provisioning profile (demo-iOS,Tunnel-iOS,WireGuardTunnel-iOS) 3.modify the Configuration 4.run the project 5.set the IP address and username password 6.press connect button

and the console log always print

17:19:27 DEBUG NetworkExtensionVPN.notifyReinstall():264 - VPN did reinstall (com.bw.business.ap02-dev.Tunnel): isEnabled=true VPNStatusDidChange: connecting 17:19:27 DEBUG NetworkExtensionVPN.notifyStatus():278 - VPN status did change (com.bw.business.ap02-dev.Tunnel): isEnabled=true, status=2 VPNStatusDidChange: disconnecting 17:19:28 DEBUG NetworkExtensionVPN.notifyStatus():278 - VPN status did change (com.bw.business.ap02-dev.Tunnel): isEnabled=true, status=5 VPNStatusDidChange: disconnected

even other methods always connecting => disconnecting = disconnected

please help me

Upvotes: 2

Views: 1250

Answers (1)

max
max

Reputation: 21

I faced with the similar issue and I've found that tunnel ID must match the bundle ID of your network extension

Example: if extension bundle ID is "com.company.vpn-tunnel" then

let protocolConfiguration = NETunnelProviderProtocol()
protocolConfiguration.providerBundleIdentifier = "com.company.vpn-tunnel"
protocolConfiguration.serverAddress = ...

For TunnelKit:

let vpn: NetworkExtensionVPN = NetworkExtensionVPN()
...
try await vpn.reconnect("com.company.vpn-tunnel", configuration: ...)

Upvotes: 2

Related Questions