Is it possible to *ask* the user to install my cartificate?
Again, this breaks down by platform:
On iOS there’s no direct way to add a trusted root certificate. The best you can do is put the certificate into a configuration profile, put that configuration profile on a server somewhere, and open its URL. That will bounce to Safari, which will bounce to the profile ingestion subsystem, which will ask the user whether they want to install the profile.
One drawback with this approach is that the profile ingestion subsystem won’t bounce back to your app when it’s done.
On macOS you can add the certificate to the keychain via standard keychain APIs and then change its trust settings via the trust settings API,
<Security/SecTrustSettings.h>
. This will trigger an authentication dialog.
(And if it's possible, since this is a VPN app, I need that also other applications such as Safari would use this certificate)
Once a certificate is installed as a trusted root it will be consulted by all trust evaluations (on macOS this is scoped to the current user unless you configure it globally, which IIRC requires actual privilege escalation).
Whether this stuff is allowed by App Review is a different question. And if App Review isn’t a concern for you (because you’re deploying via enterprise deployment) then you really are barking up the wrong tree here. In an enterprise environment your trusted root certificate should be installed via MDM.
Which brings me back to my original point:
If you’re deploying to normal users via the App Store, you should change your infrastructure to use certificates issued by a CA that’s trusted by default.
If you’re deploying to enterprise users, you should deploy your enterprise’s trusted root via MDM.
Thus, my general recommendation is that you avoid going down this path entirely.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"