Search code examples
iosswiftvpnnevpnmanager

Why personal vpn configuration not working?


I'm developing a VPN application, which installs personal VPN profile into system configuration. If my application is only one VPN application on device - all works as expected. If I install one more VPN app with another personal VPN certificate, I have problems.

enter image description here As you can see on screenshot, there are two personal certificates installed in system. One of them (not my app's certificate) is in selected state. When I try to connect to VPN from my app, my certificate does not go to selected state and VPN is not working. It works only when I select my app's certificate manually in settings. But, when I try to connect to VPN from another app, this app automatically selects proper certificate in system settings and all is working correctly.

So, my question is: is there any API to select proper certificate before connecting to VPN?

I tried to use NEVpnManager.isEnabled with no luck. I also use NEVPNManager.saveToPreferences() before trying to connect to VPN.


Solution

  • I solved my problem. The reason is NEVPNManager.isEnabled flag. It must be set to TRUE before method saveToPreferences() is called.