How to check if DER certificate has been verified / installed in iOS ?

Hi,


I want to add my own certificate to iOS device. I can do that by open the certificate from Email app or Safari browser.


After I installed it, it appear on Settings -> General -> Profile which is expected.


However I want to programmatically check if that certificate already verified / installed using Swift. Is that possible ?

Replies

However I want to programmatically check if that certificate already verified / installed using Swift. Is that possible ?

That depends on what you mean by “certificate”:

  • If you install a root certificate on the device, it will automatically be used by trust objects (SecTrust) throughout the OS. You can test whether the root certificate is installed by evaluating trust on a certificate issued by that root.

  • A client certificate (which is actually a digital identity, that is, the combination of a certificate and the private key that matches the public key in that certificate) is stored in the Apple ‘slice’ of the keychain, and thus you can’t directly test for its presence.

    Note For more details on this, see QA1745 Making Certificates and Keys Available To Your App.

    There is, however, a hackish workaround that might help you out. See this post for details.

Share and Enjoy

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

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