• <legend id='2zCR1'><style id='2zCR1'><dir id='2zCR1'><q id='2zCR1'></q></dir></style></legend>
    <i id='2zCR1'><tr id='2zCR1'><dt id='2zCR1'><q id='2zCR1'><span id='2zCR1'><b id='2zCR1'><form id='2zCR1'><ins id='2zCR1'></ins><ul id='2zCR1'></ul><sub id='2zCR1'></sub></form><legend id='2zCR1'></legend><bdo id='2zCR1'><pre id='2zCR1'><center id='2zCR1'></center></pre></bdo></b><th id='2zCR1'></th></span></q></dt></tr></i><div id='2zCR1'><tfoot id='2zCR1'></tfoot><dl id='2zCR1'><fieldset id='2zCR1'></fieldset></dl></div>

    <small id='2zCR1'></small><noframes id='2zCR1'>

        • <bdo id='2zCR1'></bdo><ul id='2zCR1'></ul>

      1. <tfoot id='2zCR1'></tfoot>
      2. 如何重置 iPhone 应用的钥匙串?

        时间:2023-10-03
        • <i id='3bZxA'><tr id='3bZxA'><dt id='3bZxA'><q id='3bZxA'><span id='3bZxA'><b id='3bZxA'><form id='3bZxA'><ins id='3bZxA'></ins><ul id='3bZxA'></ul><sub id='3bZxA'></sub></form><legend id='3bZxA'></legend><bdo id='3bZxA'><pre id='3bZxA'><center id='3bZxA'></center></pre></bdo></b><th id='3bZxA'></th></span></q></dt></tr></i><div id='3bZxA'><tfoot id='3bZxA'></tfoot><dl id='3bZxA'><fieldset id='3bZxA'></fieldset></dl></div>
            <tbody id='3bZxA'></tbody>

          1. <tfoot id='3bZxA'></tfoot>
            • <bdo id='3bZxA'></bdo><ul id='3bZxA'></ul>

                <small id='3bZxA'></small><noframes id='3bZxA'>

                  <legend id='3bZxA'><style id='3bZxA'><dir id='3bZxA'><q id='3bZxA'></q></dir></style></legend>
                  本文介绍了如何重置 iPhone 应用的钥匙串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有办法重置我的应用的钥匙串.我想知道钥匙串是否存在类似 [NSUserDefaults resetStandardUserDefaults] 的东西.即使删除应用程序后,钥匙串也不会重置.到目前为止,我知道的唯一方法是从应用程序中一一重置它们.

                  I would like to know if there is a way to reset my app's Keychain. I am wondering whether anything like [NSUserDefaults resetStandardUserDefaults] exists for keychain. Keychain is not reset even after the app is deleted. So far the only way I know is to reset them one by one from the app.

                  推荐答案

                  由于到目前为止所有的答案都依赖于您知道要删除的标识符,我想提交以下解决方案,删除所有现有的应用键(仅限 iOS)

                  As all of the answers so far rely on you knowing the identifiers you want to delete, I would like to submit the following solution that deletes ALL existing keys for the app (iOS only)

                  目标-C:

                  -(void)resetKeychain {
                      [self deleteAllKeysForSecClass:kSecClassGenericPassword];
                      [self deleteAllKeysForSecClass:kSecClassInternetPassword];
                      [self deleteAllKeysForSecClass:kSecClassCertificate];
                      [self deleteAllKeysForSecClass:kSecClassKey];
                      [self deleteAllKeysForSecClass:kSecClassIdentity];
                  }
                  
                  -(void)deleteAllKeysForSecClass:(CFTypeRef)secClass {
                      NSMutableDictionary* dict = [NSMutableDictionary dictionary];
                      [dict setObject:(__bridge id)secClass forKey:(__bridge id)kSecClass];
                      OSStatus result = SecItemDelete((__bridge CFDictionaryRef) dict);
                      NSAssert(result == noErr || result == errSecItemNotFound, @"Error deleting keychain data (%ld)", result);
                  }
                  

                  Swift 2.2:

                  func resetKeychain() {
                      self.deleteAllKeysForSecClass(kSecClassGenericPassword)
                      self.deleteAllKeysForSecClass(kSecClassInternetPassword)
                      self.deleteAllKeysForSecClass(kSecClassCertificate)
                      self.deleteAllKeysForSecClass(kSecClassKey)
                      self.deleteAllKeysForSecClass(kSecClassIdentity)
                  }
                  
                  func deleteAllKeysForSecClass(secClass: CFTypeRef) {
                      let dict: [NSString : AnyObject] = [kSecClass : secClass]
                      let result = SecItemDelete(dict)
                      assert(result == noErr || result == errSecItemNotFound, "Error deleting keychain data ((result))")
                  }
                  

                  斯威夫特 3:

                  func resetKeychain() {
                      deleteAllKeysForSecClass(kSecClassGenericPassword)
                      deleteAllKeysForSecClass(kSecClassInternetPassword)
                      deleteAllKeysForSecClass(kSecClassCertificate)
                      deleteAllKeysForSecClass(kSecClassKey)
                      deleteAllKeysForSecClass(kSecClassIdentity)
                  }
                  
                  func deleteAllKeysForSecClass(_ secClass: CFTypeRef) {
                      let dict: [NSString : Any] = [kSecClass : secClass]
                      let result = SecItemDelete(dict as CFDictionary)
                      assert(result == noErr || result == errSecItemNotFound, "Error deleting keychain data ((result))")
                  }
                  

                  这篇关于如何重置 iPhone 应用的钥匙串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:GSRegisterPurpleNamedPort SIGABRT 在 UIApplicationMain 在应用程序委 下一篇:获取 URL 字符串的域部分?

                  相关文章

                  <legend id='TDlKT'><style id='TDlKT'><dir id='TDlKT'><q id='TDlKT'></q></dir></style></legend>
                  • <bdo id='TDlKT'></bdo><ul id='TDlKT'></ul>
                1. <small id='TDlKT'></small><noframes id='TDlKT'>

                  <i id='TDlKT'><tr id='TDlKT'><dt id='TDlKT'><q id='TDlKT'><span id='TDlKT'><b id='TDlKT'><form id='TDlKT'><ins id='TDlKT'></ins><ul id='TDlKT'></ul><sub id='TDlKT'></sub></form><legend id='TDlKT'></legend><bdo id='TDlKT'><pre id='TDlKT'><center id='TDlKT'></center></pre></bdo></b><th id='TDlKT'></th></span></q></dt></tr></i><div id='TDlKT'><tfoot id='TDlKT'></tfoot><dl id='TDlKT'><fieldset id='TDlKT'></fieldset></dl></div>
                  <tfoot id='TDlKT'></tfoot>