2

私の方法:

+(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 では、この問題はありません。完璧に動作します。手伝って頂けますか?

私の英語でごめんなさい。

4

1 に答える 1

3

エラー25300は ですerrSecItemNotFound。これは、キー チェーンにそのようなアイテムがないことを意味します。

于 2013-04-06T13:28:37.487 に答える