我的方法:
+(SecKeyRef)getKeyByTagWithoutAlert:(NSString *)keyTag status:(OSStatus *) status{
*status = noErr;
SecKeyRef key = NULL;
NSMutableDictionary *queryKey = [[NSMutableDictionary alloc] init];
// Set the key query dictionary.
[queryKey setObject:(id)kSecClassKey forKey:(id)kSecClass];
[queryKey setObject:[SecKeyUtility getDataByTag:keyTag] forKey:(id)kSecAttrApplicationTag];
[queryKey setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];
[queryKey setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnRef];
*status = SecItemCopyMatching((CFDictionaryRef)queryKey, (CFTypeRef *)&key);
[queryKey release];
return key;
}
在我重新启动 iPhone4 之前,它都可以正常工作。此后 SecItemCopyMatching 返回错误,代码为 -25300,并且我的应用程序停止正常工作。在iPhone3上我没有这个问题,工作完美。 你能帮我吗?
抱歉我的英语不好。
最佳答案
错误25300
是errSecItemNotFound
,这意味着您的钥匙串(keychain)中没有这样的项目。
关于iPhone4 SecItemCopyMatching 重启后返回 -25300,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11538150/