I have really weird behavior in an iOS app. I switched from iOS 6 to iOS 7. In iOS 6, everything worked fine.
- (NSMutableDictionary *)newSearchDictionary:(NSString *)identifier { NSMutableDictionary *searchDictionary = [[NSMutableDictionary alloc] init]; [searchDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; NSData *encodedIdentifier = [identifier dataUsingEncoding:NSUTF8StringEncoding]; [searchDictionary setObject:encodedIdentifier forKey:(__bridge id)kSecAttrGeneric]; [searchDictionary setObject:encodedIdentifier forKey:(__bridge id)kSecAttrAccount]; [searchDictionary setObject:serviceName forKey:(__bridge id)kSecAttrService]; return searchDictionary; } - (NSData *)searchKeychainCopyMatching:(NSString *)identifier { NSMutableDictionary *searchDictionary = [self newSearchDictionary:identifier]; [searchDictionary setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; [searchDictionary setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; CFDataRef dataRef; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&dataRef); if (status != errSecSuccess) { #ifdef DEBUG NSLog(@"%s - No OSStatus errSecSuccess. Caused by SecItemCopyMatching", __PRETTY_FUNCTION__); #endif return nil; } NSData *result = (__bridge_transfer NSData *)dataRef; return result; }
When the application starts the function - (NSData *) searchKeychainCopyMatching: (NSString *) identifier , loads the values ββfrom the keychain. Everything works fine for a while. But after about 15 successful value requests, I get an error.
OSStatus Code -34018
The SecItemCopyMatching function returns this error code. The documentation states
@result Result code. See "Security Error Codes" (SecBase.h).
But, looking in SecBase.h, only these OSStatus codes are indicated.
enum { errSecSuccess = 0, errSecUnimplemented = -4, errSecIO = -36, errSecOpWr = -49, errSecParam = -50, errSecAllocate = -108, errSecUserCanceled = -128, errSecBadReq = -909, errSecInternalComponent = -2070, errSecNotAvailable = -25291, errSecDuplicateItem = -25299, errSecItemNotFound = -25300, errSecInteractionNotAllowed = -25308, errSecDecode = -26275, errSecAuthFailed = -25293, };
Values ββare not redefined, already checked.
And last but not least, a search dictionary:

Edit - New Information
I was debugging all day and I found some news. I am downloading a zip file containing an executable package. This is an internal application, so do not worry about paragraphs 2.7 and 2.8 in the review guidelines. After successful download of the package, a rights error appears.
NSBundle *bundle = nil; NSError *error = nil; bundle = [[NSBundle alloc] initWithPath:bundlePath]; if (!bundle) { return nil; }
Well, the package code inside does not use a keychain. Maybe this is some kind of security logic? Any clues?