Can I change the properties of a NEVPNManager from Today Extension?

Hi, I am working on a VPN app that use NEPacketTunnelProvider, the app has a Today Extension that allow me to control the VPN connection, start and stop the connection. I am able to load the NEVPNManager from Preferences in Today Extension, which is created in the Host app, and I am able to start the tunnel using this NEVPNManager.


Everything is going well.


But when I make some changes to this loaded NEVPNManager in Today Extension, for example:

manager.isOnDemandEnabled = true


and try to save the manager, I got the following error:

-[NEVPNManager saveToPreferenc:337  Failed to save configuration: Error Domain=NEVPNErrorDomain Code=1 "configuration type is wrong" UserInfo={NSLocalizedDescription=configuration type is wrong}


I am pretty sure that the configuration is valid, at least the same code works in the Host app. And if I remove the above changes (modify properties, save to preferences), the code also works in Today Extension, which means I can start the vpn tunnel normally in Today Extension.


So my question is, can I change the properties of NEVPNManager in Today Extension instead of the Host app, and save the changes to preferences, so that changes will take effect next time I start the tunnel? And how? if it's possible.


Thanks!

Replies

Historically there have been problems using

NEVPNManager
from a Today extension (r. 25869716). I don’t know for sure if those problems were ever resolved because the developer who filed that bug never responded to our requests for extra info. It’s also true that that bug was not an exact match for your scenario (the other developer was only interested in starting and stopping the tunnel, not saving a modified configuration).

It’s likely that reason why your extension is getting a “configuration type is wrong” error is because it doesn’t own the configuration; rather, it’s owned by the host app. Logically, however, it’s reasonable for app extensions to be able to manipulate the configurations created by the host app, and vice versa. As such, I recommend that you file a new bug about this.

Please post your bug number, just for the record.

Share and Enjoy

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

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

I have submitted a bug report about this issue (r. 36985759).

Hi,
Is it possible to have an update on the status of r. 36985759 as I'm unable to find it anywhere? (If I'm correct we can't browse existing radar?)
Submitted a new radar: r.43557922

If I'm correct we can't browse existing radar?

Apple Bug Reporter will only let you see bugs that you filed. There are unofficial workarounds for this but that relies on the filer to update their info. In the absence of that you can file your own bug and request that it be dup’d to the existing bug, and then you’ll be able to see the open / closed status of that bug.

And it seems that you’ve already done that:

Submitted a new radar: r.43557922

Thanks!

With regards this specific issue, the bug that kawa00 filed (r. 36985759) was dup’d to another bug (r. 27440171) that is currenly unresolved.

Share and Enjoy

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

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

FWIW the annoying bug is still there as of iOS 12. It's unbelievable.

Hey, I am facing the same issue. I reported a bug too: 50807972

I have also filed a bug for this: FB6875042


Interestingly, I found that if you delete the config from iOS settings, you can then connect from an extension, but then can't connect or disconnect from the host app. When inspecting the NEVPNProtocol of the NEVPNManager (`po vpnManager.protocolConfiguration`), there's a `pluginType` property that contains the bundleId of the app or extension - whichever did the first connection that added the config to the Settings app. Perhaps Apple is checking that this property matches the calling executable attempting to overwrite the configuration. If so, removing this check seems like the appropriate fix.


Thoughts Quinn?

Any update on this? I am sure the bug is still there on iOS 13.5.1

Any update on this?

Things haven’t changed since my last update back in 2018.

Share and Enjoy

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

December 2021 and it looks like the bug is still there.