ios 重置设备上的钥匙串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16336449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reset keychain on the device
提问by syntagma
I'm testing login flow (using KeychainItemWrapper
) inside my app on a device. How do I reset/delete keychain for my app?
我正在KeychainItemWrapper
设备上的应用程序中测试登录流程(使用)。如何重置/删除我的应用程序的钥匙串?
On the Simulator, I do it by clicking on iOS Simulator-> Reset Content and Settings....
在模拟器上,我通过单击iOS Simulator-> Reset Content and Settings... 来完成。
回答by Will
Keychain items are in iOS sandbox, users don't have access to remove unwanted keychain item. These are accessible via API's only.
钥匙串项目在 iOS 沙箱中,用户无权删除不需要的钥匙串项目。这些只能通过 API 访问。
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:[[NSBundle mainBundle] bundleIdentifier] accessGroup:nil];
//or how you access your keychain
//或者你如何访问你的钥匙串
[keychainItem resetKeychainItem];
or you can reset your device >> from the device Settings, General, Reset, Reset All Settings. But, it will reset the keychain for every app installed on the device.
或者您可以从设备设置、常规、重置、重置所有设置中重置您的设备 >>。但是,它会为设备上安装的每个应用程序重置钥匙串。
回答by Khalid Usman
- Download and add keychainWrapperfrom hereinto your project.
- Write following code in the viewController you want to reset keychain.
- 从这里下载keychainWrapper并将其添加到您的项目中。
- 在要重置钥匙串的 viewController 中编写以下代码。
CODE:
代码:
#import "KeychainItemWrapper.h"
@interface YourViewController ()
{
KeychainItemWrapper *keychainItemWrapper;
}
- (void)viewDidLoad {
[super viewDidLoad];
keychainItemWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"appname" accessGroup:nil];
}
- (IBAction)logoutButtonPressed:(id)sender {
[keychainItemWrapper resetKeychainItem];
}
回答by Nik
you can dump keychain data using Keychain dumper. Grab the following link https://github.com/ptoomey3/Keychain-Dumper
您可以使用 Keychain dumper 转储钥匙串数据。获取以下链接 https://github.com/ptoomey3/Keychain-Dumper
Just go to this url and download the zip file and unzip it. Inside this folder, the only file that we are interested is the keychain_dumper binary. The information that is allowed to be accessed by an application in the keychain is specified in its entitlements. This binary is signed with a self signed certificate with wildcard entitlements and hence it is able to access all the keychain items. There could also have been other ways to make sure all the keychain information is granted, like having the entitlements file contain all the keychain access groups or using a specific keychain access group that provides access to all the keychain data. For e.g a tool Keychain-viewer uses the following entitlments.
只需转到此网址并下载 zip 文件并解压缩即可。在这个文件夹中,我们唯一感兴趣的文件是 keychain_dumper 二进制文件。钥匙串中的应用程序允许访问的信息在其权利中指定。该二进制文件使用带有通配符权利的自签名证书进行签名,因此它能够访问所有钥匙串项目。也可能有其他方法来确保授予所有钥匙串信息,例如让权利文件包含所有钥匙串访问组或使用提供对所有钥匙串数据的访问的特定钥匙串访问组。例如,Keychain-viewer 工具使用以下权利。
com.apple.keystore.access-keychain-keys
com.apple.keystore.access-keychain-keys
com.apple.keystore.device
com.apple.keystore.device
1) Just upload this binary into your device in the /tmp folder and make sure its executable.
1) 只需将此二进制文件上传到您设备的 /tmp 文件夹中,并确保其可执行。
2) Now make sure that the keychain database file stored at the location /private/var/Keychains/keychain-2.db is world readable.
2) 现在确保存储在 /private/var/Keychains/keychain-2.db 位置的钥匙串数据库文件是世界可读的。
3) now go to terminal and you can dump your data by passing command
3)现在转到终端,您可以通过传递命令来转储数据
.keychain_dumper
.keychain_dumper
4) above command will list down all the username and password. but above will only dump out the generic and internet passwords. You can see the usage information by using the “-h” command.
4) 以上命令将列出所有用户名和密码。但上面只会转储通用和互联网密码。您可以使用“-h”命令查看使用信息。
5) You can dump all the information using the “-a” command.
5) 您可以使用“-a”命令转储所有信息。
You can read more information and example over here dumping keychain data
您可以在此处阅读更多信息和示例 转储钥匙串数据