Developing VPN App using OpenVPN

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 state


We 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

I have no insight into the VPN libraries you’re using. If you need help with those, you’ll have to pursue that via whatever support channel those libraries provide. I can, however, help you with the Apple side of this.

To that end:

  • Does your provider’s

    startTunnel(…)
    method get called?
  • Do you call the

    setTunnelNetworkSettings(…)
    ? What does the
    NETunnelNetworkSettings
    look like?
  • Does

    setTunnelNetworkSettings(…)
    call its completion routine? If so, what do you see for the
    error
    parameter?
  • Do you then call the completion routine that was passed to

    startTunnel(…)
    ? What do you pass in to its
    error
    parameter?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Does your provider’s

startTunnel(…)
method get called? -- Nope.


OK then, does your provider’s initialiser get called.

IMPORTANT You won’t be able to set a breakpoint on that, so you’ll need to determine this by logging. See this post for my suggestions in that regard.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

We are trying to connecting vpn (TCP & UDP) through “.ovpn” configuration using TunnelKit, But after calling startTunnel NEPacketTunnelProvider is not initiating How do I create an OVPN file configuration format

using TunnelKit

You might have more luck asking this via the support channel for the third-party library you’re using.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Developing VPN App using OpenVPN
 
 
Q