SecItemAdd creates two identifiers

I am developing an IPhone application that needs a certificate to call some services, so I add a certificate to my keychain that does this:

 SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certificadoData);
 NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
 [dictionary setObject:(__bridge id)kSecClassCertificate forKey:(__bridge id)kSecClass];
 [dictionary setObject:(__bridge id)(cert) forKey:(__bridge id<NSCopying>)(kSecValueRef)];
 OSStatus status = SecItemAdd((__bridge CFDictionaryRef)dictionary, NULL);

When I list the entire kSecClassIdentity value before this code, the result will not be, and after this code two identifiers and one certificate are returned. When I tried to use identifiers, one works correctly and the other does not. Why does SecItemAdd create two kSecClassIdentity for one kSecClassCertificate? And how can I determine the right one?

+4
source share
1 answer

, reaserch , , .

, ,

value: kSecAttrKeyClassPrivate / kSecAttrKeyClassPublic
key: kSecAttrKeyClass

, SecItemCopyMatching :

NSMutableDictionary *filterDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                             (__bridge id)kSecClassIdentity, kSecClass,
                                             kSecMatchLimitAll,              kSecMatchLimit,
                                             kCFBooleanTrue,                 kSecReturnRef,
                                             kSecAttrKeyClassPrivate,        kSecAttrKeyClass,
                                             nil];
+1

All Articles