Hi, I want to develop an enterprise VPN app with a custom protocol. I'm following the documentation but I have no clue how to start, is there any guide I can follow?
Oh, I shoulda mentioned that Network Extension Resources has links to the docs, samples, and so on that do exist. I expect there’s a bunch of third-party resources as well.
OK. That simplifies things because there’s only one deployment path. See TN3134 Network Extension provider deployment.
Getting started with a packet tunnel provider is reasonably straightforward these days. There’s an Xcode target template under iOS > Network Extension. It takes care of all the packaging concerns. You then fill in startTunnel(options:completionHandler:)
method override to:
-
Start your tunnel. You can use normally networking APIs for this, so either Network framework or BSD Sockets. See TN3151 Choosing the right networking API for more on that.
-
Once the tunnel is up, apply the settings for that tunnel by calling the
setTunnelNetworkSettings(_:completionHandler:)
method. -
When that’s done, call the completion handler that was passed to your
startTunnel(options:completionHandler:)
method. This tells the system that the tunnel’s interface is up and functioning. -
Finally, read outgoing packets from, and write incoming packets to, the tunnel interface using the
self.packetFlow
property.
The most complicated part of this is the tunnel network settings, and there’s specific advice on that front in Routing your VPN network traffic.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"