清除 iPhone 钥匙扣

发布于 2024-09-03 09:07:54 字数 57 浏览 6 评论 0原文

有没有办法可以清除 iPhone 应用程序的钥匙串?清除命令或所有键的列表,以便我可以自己删除它们。

Is there a way I can purge the keychain for my iphone app? Either a purge command or a listing of all keys so I can delete them myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-09-10 09:07:54

不存在清除命令之类的东西。
无论如何,由于您的应用程序可以访问的钥匙串专用于您的应用程序,因此您只能轻松地跟踪您在其中写入的内容并将其删除。

您可以实现自己的清除方法,该方法将简单地一一删除您可以保存在钥匙串中的所有可能的数据类型。以下是我清除所有 GenericPassword 条目的方法:

- (BOOL)deleteKeychainData
{
    /* delete custom data */
    NSMutableDictionary *searchData = [NSMutableDictionary new];
    [searchData setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
    [searchData setObject:kTagKeychainService forKey:(id)kSecAttrService];

    OSStatus statusData = SecItemDelete((CFDictionaryRef)searchData);
    [searchData release];

    CHECK_CONDITION1(statusData == errSecSuccess
                     || statusData == errSecItemNotFound,
                     @"Error while deleting keychain data, OSStatus == %d", statusData);

    /* delete assymetric keys*/
    return [self deleteKeyPair];
}

因此,您需要做的是为所有可能的 kSecClass 值调用此方法。
注意不同的数据类型需要设置不同的字典标志。

问候

There is no such thing as purge command.
Anyway since the keychain your application has access to is dedicated for your application only you can easily keep track of what you have written in it and delete it.

You can implement your own purge method that will simply delete one by one all possible data types that you can save in keychain. Below is how I purge all my GenericPassword entries:

- (BOOL)deleteKeychainData
{
    /* delete custom data */
    NSMutableDictionary *searchData = [NSMutableDictionary new];
    [searchData setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
    [searchData setObject:kTagKeychainService forKey:(id)kSecAttrService];

    OSStatus statusData = SecItemDelete((CFDictionaryRef)searchData);
    [searchData release];

    CHECK_CONDITION1(statusData == errSecSuccess
                     || statusData == errSecItemNotFound,
                     @"Error while deleting keychain data, OSStatus == %d", statusData);

    /* delete assymetric keys*/
    return [self deleteKeyPair];
}

So what you need to do is call this method for all possible kSecClass values.
NOTE that different data types would require different dictionary flags to be set.

regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文