Docs suggest that an identity consists of a private key packaged with the certificate that contains and vouches for the corresponding public key.
Is it possible to create an identity backed by a private key generated in secure enclave?
The code snippet you posted contains a called to SecIdentityCreateWithCertificate. That’s only available on macOS. Are you doing this on the Mac?
If so, be aware that SE keys always end up in the data protection keychain. If you want such a key to match up with a certificate to form a digital identity, you have to add the certificate to the data protection keychain as well. By default certificates you add go into the file-based keychain.
Also, when working with the data protection keychain it’s likely that macOS-only functions, like SecIdentityCreateWithCertificate, won’t work as you expect. Stick to stuff that’s available on both macOS and iOS.
For more background to the above, read TN3137 On Mac keychain APIs and implementations.
When debugging problems like this I usually do the following:
-
Call
SecItemCopyMatchingto get the attributes of the key. -
Call
SecItemCopyMatchingto get the attributes of the certificate. -
Make sure that public key hash values line up. See SecItem attributes for keys for the details.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"