Created
March 31, 2014 19:24
-
-
Save xdumaine/9900162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (OSStatus)extractIdentity:(CFDataRef)inP12Data :(SecIdentityRef*)identity { | |
OSStatus securityError = errSecSuccess; | |
CFStringRef password = CFSTR("MyCertificatePassword"); | |
const void *keys[] = { kSecImportExportPassphrase }; | |
const void *values[] = { password }; | |
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL); | |
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL); | |
securityError = SecPKCS12Import(inP12Data, options, &items); | |
if (securityError == 0) { | |
CFDictionaryRef ident = CFArrayGetValueAtIndex(items,0); | |
const void *tempIdentity = NULL; | |
tempIdentity = CFDictionaryGetValue(ident, kSecImportItemIdentity); | |
*identity = (SecIdentityRef)tempIdentity; | |
} | |
if (options) { | |
CFRelease(options); | |
} | |
return securityError; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment