How to delete all keychain items accessible to an app?
How to delete all keychain items accessible to an app?
I have stray keychain items on iOS (probably written by old version of app) that I need to delete. Is there an easy way to achieve this?
Answer by AgnosticDev for How to delete all keychain items accessible to an app?
You could take a look at the KeyChain Access application found in the Utilities folder. If you launch the application and click on "All Items," it should display all the items you have created with this specific computer. The developer ones usually start with com.
Answer by sqreept for How to delete all keychain items accessible to an app?
Thanks to Daij-Djan I got to this solution:
for (id secclass in @[ (__bridge id)kSecClassGenericPassword, (__bridge id)kSecClassInternetPassword, (__bridge id)kSecClassCertificate, (__bridge id)kSecClassKey, (__bridge id)kSecClassIdentity]) { NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys: secclass, (__bridge id)kSecClass, nil]; SecItemDelete((__bridge CFDictionaryRef)query); }
Answer by Daij-Djan for How to delete all keychain items accessible to an app?
do it for all classes
NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword, (__bridge id)kSecClassInternetPassword, (__bridge id)kSecClassCertificate, (__bridge id)kSecClassKey, (__bridge id)kSecClassIdentity]; for (id secItemClass in secItemClasses) { NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass}; SecItemDelete((__bridge CFDictionaryRef)spec); }
Answer by Alex Sorokoletov for How to delete all keychain items accessible to an app?
Xamarin iOS version (MonoTouch) of accepted answer on How to delete all keychain items accessible to an app is below:
foreach (var recordKind in new []{ SecKind.GenericPassword, SecKind.Certificate, SecKind.Identity, SecKind.InternetPassword, SecKind.Key, }) { SecRecord query = new SecRecord(recordKind); SecKeyChain.Remove(query); }
If you want to make sure you indeed delete the records, you may during development check number of items in KeyChain of specific kind before and after with this code:
SecStatusCode scc; var records = SecKeyChain.QueryAsRecord(new SecRecord(SecKind.GenericPassword), 1000, out scc);
Answer by Jawboxer for How to delete all keychain items accessible to an app?
I rewrote Daij-Djan's answer in Swift:
let secItemClasses = [kSecClassGenericPassword, kSecClassInternetPassword, kSecClassCertificate, kSecClassKey, kSecClassIdentity] for secItemClass in secItemClasses { let dictionary = [kSecClass as String:secItemClass] SecItemDelete(dictionary) }
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment