I have a MacOS network extension that activates 3 network "Proxies" (TransparentProxy, AppProxy and DNSProxy).
To activate the proxies I do:
NEAppProxyProviderManager.loadAllFromPreferences {
saveToPreferences { error in
if (error) {
/* failed to save */
}
/* saved */
}
}
Now I do this 3 times (once for each proxy). The behavior I observe is the following:
Once the "saveToPreferences()" is called for the first time the app is installed, user gets an approval popup.
Even before user clicks anything, the first 2 calls to "saveToPreferences" fail (both with the same message):
Failed to save configuration MyTransparentProxy: Error Domain=NEConfigurationErrorDomain Code=10 “permission denied” UserInfo={NSLocalizedDescription=permission denied}
The third call to "saveToPreferences()" does NOT return until a user either accepts or rejects the "allow vpn configuration" pop up.
My question is, how can I make all the calls to block the completion callback until user decision ?
For now, I figured out that this works as workaround: In the initialization of the first proxy I do:
NEAppProxyProviderManager.loadAllFromPreferences {
saveToPreferences { error in
if (error) {
/* failed to save */
}
/* saved */
/* here I start the “next” proxies */
StartNextProxy();
}
}
In this case the first one is blocked until user accepts the pop up and once he does I start the second and the third proxies. This ensure avoidance of "permission denied" error as only one "saveToPreferences()" call waits for user approval.
This doesn’t feel like the correct method to me, is there a way for multiple proxy manager to wait for "VPN Configuration" approval event ?
Thanks !