Last active
April 5, 2018 14:46
-
-
Save fmessina/4820a9cb6abd3e137b3420ccdbc149d4 to your computer and use it in GitHub Desktop.
Print all the existing keys in the iOS keychain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)showKeychainKeys { | |
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys: | |
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnAttributes, | |
(__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit, | |
nil]; | |
NSArray *secItemClasses = [NSArray arrayWithObjects: | |
(__bridge id)kSecClassGenericPassword, | |
(__bridge id)kSecClassInternetPassword, | |
(__bridge id)kSecClassCertificate, | |
(__bridge id)kSecClassKey, | |
(__bridge id)kSecClassIdentity, | |
nil]; | |
for (id secItemClass in secItemClasses) { | |
[query setObject:secItemClass forKey:(__bridge id)kSecClass]; | |
CFTypeRef result = NULL; | |
SecItemCopyMatching((__bridge CFDictionaryRef)query, &result); | |
NSLog(@"RESULT %@", (__bridge id)result); | |
if (result != NULL) CFRelease(result); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment