How to turn on VPN from iOS app? (Private APIs OK)

Giorgos Ath picture Giorgos Ath · Feb 18, 2013 · Viewed 8.4k times · Source

When an iOS Device goes into "sleep mode", even a configured VPN is, unfortunately, turned off.

A customer that wants an app for his iPad has to use VPN for security, so anything must be done through VPN. The app has to synchronize a lot, but the iOS device might turn off the VPN by itself. That's why I just need to trigger it again every time i need an internet connection (or keep it alive).

Do any of you guys have anything in mind?

Even using Private API is ok (the app will only be distributed to a customer, not through App Store).

Or using any app like Cisco AnyConnect would do the job.

Answer

Victor Ronin picture Victor Ronin · Feb 19, 2013

Two ideas:

1) You can create a configuration profile with VPN on demand. This require client certificat authentication though. My guess that if some application will try to access domains or hosts defined in VPN on demand section in sleep mode, VPN will be turned on.

Update: At some moment Apple was sued regarding VPN on demand, so I believe they dropped this feature and after returned it back modified. It's good idea to read this article for iOS 7: http://support.apple.com/kb/ts4550

2) Idea which I offered for this question (iOS6 toggle WiFi on non-jailbroken device). Here is the copy of text from there:

I think it make sense to look at SystemConfiguration.framework.

It has set of API to work with different connection interfaces, which are defined here: http://developer.apple.com/library/mac/#documentation/Networking/Reference/SCNetworkConfiguration/Reference/reference.html

This one is private API.

Update: I believe there were some changes in SystemConfiguration and Apple tightened security around this framework.

3) Apple may grant to some applications additional entitlements, so they can build functionality which no other application can build. As example, VPN client companies (like Cisco) got special entitlements to build what in iOS called "VPN plugins", which is essentially VPN client.