How to get SecIdentityRef from SecCertificateRef and PrivateKey?

How to create SecIdentityRef if you have SecCertificateRef and Private Key in iOS? I have an X509 certificate that is transmitted from the server and its associated private key, but now I'm trying to establish trust in NSURLCredentials .

A similar question was asked here. How to install SecIdentityRef on iPhone keychain? (Without .p12)

As mentioned in a previous post, I first created a SecCertificateRef using SecCertificateCreateWithData and then added it to the key chain using SecItemAdd , but I don't know what to do now to generate a SecIdentityRef.

Many thanks,
Manish
Postscript - I do not have enough comments to comment on a post asking a new question.

+5
source share
1 answer

As I understand it, SecIdentityRef do not exist as separate entries in the keychain. When you get the identifier using SecItemCopyMatching() , it finds the certificate and the corresponding private key and returns an identity that is just a reference to this pair (cert, key). As far as I know, the only way to create a SecIdentityRef is to insert the private key and certificate for that key into your keychain, and then search for identifiers.

+5
source

Source: https://habr.com/ru/post/1205065/


All Articles