我已经成功地分别使用钥匙串和钥匙串共享(在多个设备之间同步钥匙串项)来实现TouchID.当我尝试同时执行它们时,我收到错误"-50",这是无效参数.从下面的代码中,删除kSecAttrAccessControl或kSecAttrSynchronizable按预期工作.
根据我的经验(阅读 - 几天的挫折)到目前为止,并基于一些钥匙串API简化工具(如UICKeychainStore)的功能,似乎如果我使用Touch ID身份验证,钥匙串共享将无法工作,反之亦然.我正在寻找可以说明但无法找到它的Apple文档.
我已经浏览了Apple的SecItem.h页面,我找到了一个有用的信息,其中包含有关kSecAttrAccessible和kSecAttrSynchronizable的信息:"如果在OS X或iOS上都指定了这两个属性,则kSecAttrAccessible密钥的值可能只是其名称之一不会以"ThisDeviceOnly"结尾,因为那些不能同步到另一台设备."但是,我没有使用"ThisDeviceOnly"(我目前正在使用kSecAttrAccessibleAlways进行测试)
您能否指出Apple是否以及在何处记录此限制?这将有助于我记录它的记录,并继续前进.谢谢.
- (void)addKeychainItemWithIdentifier:(NSString *)identifier andData:(NSData *)data {
CFErrorRef error = NULL;
SecAccessControlRef sacObject;
sacObject = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
kSecAttrAccessibleAlways,
kSecAccessControlUserPresence, &error);
if(sacObject == NULL || error != NULL)
{
NSString *msg0 = [NSString stringWithFormat:NSLocalizedString(@"SEC_ITEM_ADD_CAN_CREATE_OBJECT", nil), error];
[self printResultWithMessage:msg0];
return;
}
NSDictionary *attributes = @{
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecValueData: data,
(__bridge id)kSecAttrAccessible:(__bridge id)kSecAttrAccessibleAlways,
(__bridge id)kSecAttrService: identifier,
(__bridge id)kSecAttrSynchronizable:(__bridge …Run Code Online (Sandbox Code Playgroud) 基本上我正在尝试做的是找出一种使用Touch ID加密数据的方法.
遗憾的是,我没有找到使用Touch ID创建encryptionKey的方法,因为LAContextAPI只返回aye/nay响应.
我正在应用程序中实现不同的登录方法.支持的登录方法是密码,PIN码和Touch ID.用户可以自由选择他/她想要的任何登录方法.
但是,只有密码才会发送到服务器,服务器将对用户进行身份验证.因此,只有密码存储在钥匙串中.
的encryptionKey,用于第一加密和然后存储密码在钥匙串中,使用任何方法,用户选择作为登录方法创建的.
如果用户选择使用PIN码,encryptionKey则从该PIN码导出,当用户选择密码作为登录方法时,可以说同样的.
我在互联网上搜索过,但只发现了我已经害怕的东西.
由于iOS只返回一个true或false来自Secure Enclave,因此无法创建一个encryptionKey.
我知道钥匙串是自己加密的,但出于安全考虑(请不要详细说明)我需要一个存储在钥匙串中的加密密码.
背后的原因存储在钥匙串加密数据是因为钥匙串可以通过越狱的装置被破坏.由于我正在开发的应用程序允许用户查看(主要)企业敏感数据,因此我需要考虑越狱.
我有许多地方描述的LocalAuthentication的以下实现.
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Logging in with Touch ID", reply: { (success : Bool, error : NSError? ) -> Void in
dispatch_async(dispatch_get_main_queue(), {
if success {
let alert = UIAlertController(title: "Success", message: "", cancelButtonTitle: "Great!")
self.presentViewController(alert, animated: true, completion: nil)
}
if let error = error {
var message :String
switch(error.code) {
case LAError..AuthenticationFailed:
message = "There was a problem verifying your identity."
case LAError..UserCancel:
message = "You pressed cancel."
case LAError..UserFallback:
message = "You pressed password."
default:
message = "Touch …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中添加了ios-8的新touchID API.它通常按预期工作,但在我的手指已经在主页按钮时输入应用程序 - API的成功回调被调用但弹出窗口仍然出现在屏幕上.按下CANCEL后,UI变得无响应.
我已通过设置localizedFallbackTitle为"使用密码" 自定义了后备按钮.有效.但是在我将iPhone更新到iOS 8.3之后,TouchID视图上的后备按钮消失了.
这是API更新还是iOS 8.3的错误?
怎么解决?
我正在深入研究Apple的Touch ID,更准确地说是Local Authenticator.截至目前的文档非常稀少.它主要是这个:
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = <#String explaining why app needs authentication#>;
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
// User authenticated successfully, take appropriate action
} else {
// User did not authenticate successfully, look at error and take appropriate action
}
}];
} else {
// Could not evaluate policy; look at authError and present an appropriate message to …Run Code Online (Sandbox Code Playgroud) 我一直在努力将Touch ID支持集成到我正在处理的应用程序中.然而,它表现得非常不一致.我看到的一个常见问题是在新的应用程序启动它按预期工作,但随后在应用程序的背景,并将其带到前台我收到一个错误
evaluatePolicy:localizedReason:reply:
Run Code Online (Sandbox Code Playgroud)
它甚至没有多大意义(我从未看到过触摸警报)
Error Domain=com.apple.LocalAuthentication Code=-1004 "User interaction is required." UserInfo=0x171470a00 {NSLocalizedDescription=User interaction is required.}
Run Code Online (Sandbox Code Playgroud)
我已经尝试在应用程序已经运行时显示touchid警报,当它刚刚被预先考虑时,似乎并不重要.在最初的应用程序启动后,每次都会破坏它.
其他人遇到这个?
作为参考,这是我正在使用的代码:
if (_useTouchId && [LAContext class]) {
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
_didPresentTouchId = YES;
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Use your Touch ID to open *****" reply:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^ {
if (success) {
_isClosing = YES;
[self hide];
if (_successBlock) {
_successBlock();
}
}
else if (error && error.code != …Run Code Online (Sandbox Code Playgroud) 我正在我的应用程序中实现身份验证,并允许用户使用Touch ID进行身份验证.我还希望通过"输入密码"按钮为他们想要输入密码的时候启用后备.
我目前的代码有:
NSError *error = nil;
LAContext *context = [[LAContext alloc] init];
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Login to My app"
reply:^(BOOL success, NSError *error) {
// do something
}
];
} else {
// do something
}
Run Code Online (Sandbox Code Playgroud)
触摸ID部分工作时,"输入密码"按钮不显示.

我可以让它显示的唯一方法是,如果我通过使用未注册的不同手指未通过触摸验证.

我宁愿不必强迫用户通过身份验证来显示该按钮.
我已经通过几个教程和博客检查,看看我是否遗漏了任何东西,但我没有找到任何东西.


从图片中,似乎应该显示"输入密码".我在iOS8.2和8.3的iPhone上使用8.3 SDK
iOS设置应用程序有很多带有prefs网址的列表,用于在设置应用中打开特定网站(例如/sf/answers/577277011/).不幸的是,我找不到网址才能打开触摸ID和密码设置.
有人知道这个网址方案吗?
是否可以在LAContext.evaluatePolicy通话后以编程方式取消TouchID警报对话框?如果是的话:怎么样?
ios ×10
touch-id ×10
ios8 ×3
fingerprint ×2
keychain ×2
objective-c ×2
encryption ×1
ios8.3 ×1
settings ×1
swift ×1
touch ×1