I\'m fighting with a client certificate authentication. When a server needs a credential (a certificate in this case), this method is invoked from NSURLConnection d
You can also search for identity in keychain if you store this information there:
+ (SecIdentityRef)dumpSecIdentityRef
{
OSStatus err;
CFArrayRef result;
CFIndex resultCount;
CFIndex resultIndex;
result = NULL;
err = SecItemCopyMatching((__bridge CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge id)kSecClassIdentity,
kSecClass, kSecMatchLimitAll,
kSecMatchLimit, kCFBooleanTrue,
kSecReturnRef, kCFBooleanTrue,
kSecReturnAttributes, nil],
(CFTypeRef *) &result);
if ((result != NULL) && (err == noErr)) {
NSMutableArray *identitiesArray = [NSMutableArray new];
resultCount = CFArrayGetCount(result);
for (resultIndex = 0; resultIndex < resultCount; resultIndex++) {
NSDictionary * thisResult;
thisResult = (__bridge NSDictionary *) CFArrayGetValueAtIndex(result, resultIndex);
NSLog(@"%@", (__bridge id)(result));
[identitiesArray addObject:thisResult];
}
CFRelease(result);
//TO DO - choose correct identity object from array.
SecIdentityRef myIdentity = (__bridge SecIdentityRef)([[identitiesArray objectAtIndex:0] valueForKey:@"v_Ref"]);
return myIdentity;
}
return nil;
}