1

I am trying to create an ios vpn client using Tunnelkit. I am following this tutorial.

https://github.com/passepartoutvpn/tunnelkit

am able to compile and run the application, but when I try to connect, the app crashes and throwing.

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: TunnelKit.OpenVPNTunnelProvider.ProviderConfigurationError.credentials(details: "keychain.set()")

Anyone who had already set up tunnel kit OpenVPN, please help to resolve this issue.

func connect() {
    let server = textServer.text!
    let domain = textDomain.text!
    let hostname = ((domain == "") ? server : [server, domain].joined(separator: "."))
    let port = UInt16(textPort.text!)!
    let socketType: SocketType = switchTCP.isOn ? .tcp : .udp

    let credentials = OpenVPN.Credentials(textUsername.text!, textPassword.text!)
    let cfg = Configuration.make(hostname: hostname, port: port, socketType: socketType)
    let proto = try! cfg.generatedTunnelProtocol(
        withBundleIdentifier: tunnelIdentifier,
        appGroup: appGroup,
        credentials: credentials
    )
    let neCfg = NetworkExtensionVPNConfiguration(title: "new title", protocolConfiguration: proto, onDemandRules: [])
    vpn.reconnect(configuration: neCfg) { (error) in
        if let error = error {
            print("configure error: \(error)")
            return
        }
    }
}
Sathya Baman
  • 3,424
  • 7
  • 44
  • 77

2 Answers2

0

You need to follow the integration steps. https://github.com/passepartoutvpn/tunnelkit#demo

Enable App Groups and Keychain Sharing capabilities

munibsiddiqui
  • 435
  • 5
  • 15
0

make sure the appGroup value is the same which you set in your target/Signings & Capabilities/App Groups