This is what we did
1) First generate asymmetric RSA public and private keypair using SecKeyGeneratePair
2) Read private key data genearted from 1) using SecKeyCopyExternalRepresentation
3) Generate PKCS Certificate signing request using OpenSSL
4) Send to the server
5) Server returns signed x509 certificate
6) We write this x509 certificate into keychain :)
Once we have done all of that above, we currently retrieve a list of all identity objects and perform linear search to find the identity that we're interested in by looking at the issuer name using below code
NSDictionary *getQuery = @{ (id)kSecClass: (id)kSecClassIdentity,
(id)kSecReturnAttributes:(__bridge id)(kCFBooleanTrue),
(id)kSecMatchLimit : (__bridge id)kSecMatchLimitAll,
(id)kSecReturnRef: (__bridge id)(kCFBooleanTrue),
};
status = SecItemCopyMatching((__bridge CFDictionaryRef)getQuery, (CFTypeRef *)&identityArr);
Then uses this filtered identity for NSURLCredential - credentialWithIdentitiy API,
but I thought it would also be equally valid to simply generate Identity object using
SecIdentityCreateWithCertificate API and use it instead :)
I was wondering if you could help to confirm whether it is valid for me to use
1) SecIdentityCreateWithCertificate to generate Identity dynamically from x509 cert from above, and then use it with
NSURLCredential credentialWithidentity?
2) additionally, would it also be ok to use such a dynamically generated identity with SecIdentitySetPreferred ?
Thanks,
Peter
Topic:
Privacy & Security
SubTopic:
General
Tags: