iPhone4 SecItemCopyMatching returns -25300 after r

2019-07-21 10:03发布

问题:

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.

回答1:

Error 25300 is errSecItemNotFound, which means that there is no such item in your key chain.