SecItemAdd creating two identities

眉间皱痕 提交于 2019-12-03 16:46:49

I just had to solve this issue and from my reaserch the issue is that one of the identities contains private key and the other one contains public key.

So when you're trying to retrieve the identity you have to add

value: kSecAttrKeyClassPrivate / kSecAttrKeyClassPublic
key: kSecAttrKeyClass

to the dictionary used as filter in SecItemCopyMatching e.g.:

NSMutableDictionary *filterDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                             (__bridge id)kSecClassIdentity, kSecClass,
                                             kSecMatchLimitAll,              kSecMatchLimit,
                                             kCFBooleanTrue,                 kSecReturnRef,
                                             kSecAttrKeyClassPrivate,        kSecAttrKeyClass,
                                             nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!