From 4ee6eed23dd3ac1b43447590668e7f132b2d913e Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 21 Oct 2014 19:57:37 -0400 Subject: [PATCH] -deleteItem: Explain some Mac-only code --- SSKeychain/SSKeychainQuery.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SSKeychain/SSKeychainQuery.m b/SSKeychain/SSKeychainQuery.m index b93c620..99875b6 100644 --- a/SSKeychain/SSKeychainQuery.m +++ b/SSKeychain/SSKeychainQuery.m @@ -71,6 +71,15 @@ - (BOOL)deleteItem:(NSError *__autoreleasing *)error { #if TARGET_OS_IPHONE status = SecItemDelete((__bridge CFDictionaryRef)query); #else + // On Mac OS, SecItemDelete will not delete a key created in a different + // app, nor in a different version of the same app. + // + // To replicate the issue, save a password, change to the code and + // rebuild the app, and then attempt to delete that password. + // + // This was true in OS X 10.6 and probably later versions as well. + // + // Work around it by using SecItemCopyMatching and SecKeychainItemDelete. CFTypeRef result = NULL; [query setObject:@YES forKey:(__bridge id)kSecReturnRef]; status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);