My method:
+(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;
}
And it works fine until I restart my iPhone4. After this SecItemCopyMatching returns error with code -25300 and my app stoping work properly. On iPhone3 I don't have this problem, just work perfect. Can you help me?
Sorry for my english.