Posts

Post not yet marked as solved
5 Replies
1.9k Views
Hello Eskimo,Hope you are doing well,I am looking for a solution for VPN.i am building iOS app for VPN using OpenVPN i tried many libraries but didn't got success. it is starting with connecting status and immediately it is getting disconnected.Can you please help me on that?Appreciate your help.FYI, below is the code snipet for your reference.In iOS after session.startTunnel() connection status stops on connecting stateWe are trying to connecting vpn (TCP & UDP) through “.ovpn” configuration using TunnelKit, But after calling startTunnel NEPacketTunnelProvider is not initiating.private func makeProtocol() -> NETunnelProviderProtocol { let credentials = OpenVPN.Credentials(textUsername.text!, textPassword.text!) let configurationFileURL = Bundle.main.url(forResource: “xyz”, withExtension: "ovpn") do { let file = try OpenVPN.ConfigurationParser.parsed(fromURL: configurationFileURL!).configuration var builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: file) builder.mtu = 1450 builder.shouldDebug = true builder.masksPrivateData = false let configuration = builder.build() return try! configuration.generatedTunnelProtocol( withBundleIdentifier: ViewController2.tunnelIdentifier, appGroup: ViewController2.appGroup, credentials: credentials ) } catch { print("Failed to send a message to the provider") return NETunnelProviderProtocol() } }func connect() { configureVPN({ (manager) in return self.makeProtocol() }, completionHandler: { (error) in if let error = error { print("configure error: \(error)") return } self.currentManager?.isEnabled = true let session = self.currentManager?.connection as! NETunnelProviderSession do { try session.startTunnel() print("start Tunnel called") } catch let e { print("error starting tunnel: \(e)") } })}Again thanks in advanced
Posted Last updated
.