How to manage VPN connection from the app when .mobileconfig profile installed ?

Hi Guys,


I am trying to make "Always-On" VPN and an app that is ability to manage VPN connection(As OpenVPN Connect).

I created a VPN profile using "Apple Configurator 2".


After installing profile, I want to manage from the app. How do I do ?


In other words, I installed a VPN profile (.mobileconfig) once and manage VPN connection from the app.

Is there any interface(API) between VPN profile and application ?


Thanks.

I’m confused about your requirements, so I’m going to sprout some factoids and ask you to follow-up with clarifications if you’re still stuck. So:

  • If you set up a Personal VPN configuration (using

    NEVPNManager
    to configure the built-in IKEv2 or IPsec VPN transports), you can manage that connection using the
    NEVPNConnection
    instance that’s accessible via the
    connection
    of
    NEVPNManager
    .
  • If your app implements a custom VPN transport via the Network Extension provider mechanism, you can manage its configurations programmatically using

    NETunnelProviderManager
    . Configurations creating via configuration profile will be visible to this mechanism.
    NETunnelProviderManager
    is a subclass of
    NEVPNManager
    , and so it has a
    connection
    property as well. You can cast that to a
    NETunnelProviderSession
    and use that to manage the connection associated with the configuration.
  • There’s no way to manage VPN configurations for VPN transports you don’t ‘own’ (except the Personal VPN case I mentioned above). This includes configurations created programmatically, configurations created by the user, and configurations created via a configuration profile. It also includes built-in VPN transports and third-party VPN transports.

  • Always-on VPN is an Apple VPN transport (a flavour of IKEv2) and thus falls under the last point.

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"
How to manage VPN connection from the app when .mobileconfig profile installed ?
 
 
Q