Skip to content

Instantly share code, notes, and snippets.

@fmessina
Last active April 5, 2018 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmessina/4820a9cb6abd3e137b3420ccdbc149d4 to your computer and use it in GitHub Desktop.
Save fmessina/4820a9cb6abd3e137b3420ccdbc149d4 to your computer and use it in GitHub Desktop.
Print all the existing keys in the iOS keychain
+ (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