Post

Replies

Boosts

Views

Activity

Connection to IKEv2 VPN Server
I'm Using NEVPNManager to Connect to IKEv2 VPN Server which uses certificate in p12 or .cer file to authenticate for connection. here my code snippet for connecting to server.     let vpnManager = NEVPNManager.shared();         vpnManager.loadFromPreferences { (_: Error?) in                      }                  let p = NEVPNProtocolIKEv2()         p.authenticationMethod = NEVPNIKEAuthenticationMethod.none         p.useExtendedAuthentication = true         p.serverAddress = "******"         p.remoteIdentifier = "*****"         p.disconnectOnSleep = false         let certificateFile = Bundle.main.path(forResource: "myvpn", ofType: "p12")!         let certificateData = NSData(contentsOfFile: certificateFile)!         p.identityData = certificateData as Data         p.identityDataPassword = "*******"         vpnManager.protocolConfiguration = p         vpnManager.localizedDescription = "Apple VPN"         vpnManager.isEnabled = true         vpnManager.saveToPreferences(completionHandler: nil)         vpnManager.loadFromPreferences { (_: Error?) in                      }                  do{             try vpnManager.connection.startVPNTunnel()         }catch{             print(error)         } This Code will create a vpn profile in vpn section of iOS setting part. The Problem is that I can not understand how should I pass the .p12 file or .cer file to NEVPNProtocolIKEv2 for authentication. Note : Currently I am able to connect to server by installing .p12 and .cer file manually in setting. so the server is up and working without any problem. Is this way wrong ? How can I connect to IKEv2 VPN Server Programmatically? Thanks
1
0
721
Sep ’20