我的方法:
+(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 上我没有这个问题,只是工作完美。你能帮助我吗?
对不起我的英语不好。