不過理論上 App 不能存取別其它 App 的 keychain 資料, 所以這勉強不算安全漏洞吧。若希望使用者重新安裝 App 時, 不會用到之前存在 keychain 的資料, 可在安裝後第一次啟動時先刪除 keychain 資料:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Clear keychain on first run in case of reinstallation if (![[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"]) { // Delete values from keychain here 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: (__bridge id)secItemClass}; SecItemDelete((__bridge CFDictionaryRef)spec); } [[NSUserDefaults standardUserDefaults] setValue:@"1strun" forKey:@"FirstRun"]; } //...Other stuff that usually happens in didFinishLaunching }
參考資料:
沒有留言:
張貼留言