首页 文章

在iOS8中,只能通过指纹识别才能访问钥匙串

提问于
浏览
4

我需要在iOS钥匙串上安全地存储/检索项目 .

从Apple KeyChainServicesReference doc(https://developer.apple.com/library/ios/documentation/security/Reference/keychainservices/Reference/reference.html)我使用SecItemCopyMatching调用检索钥匙串项 . 后者弹出一个系统提示,用于对允许使用指纹的本地钥匙串进行身份验证,或者使用4位电话密码 .

虽然我认为auth具有指纹安全性,但它是4位数的PIN选项,可以降低我当前的安全性 . 所以,我的问题是:有没有办法只用指纹选项查询钥匙串(没有密码选项,如果指纹验证失败,它只是失败,没有回退到4位密码)

我已经研究过LocalAuthentication,虽然后者提供了我需要的确切流程,但洛杉矶并没有让我访问钥匙串,所以洛杉矶对我来说毫无用处

非常感谢提前

3 回答

  • 1

    在LAContext.h中:

    /// Fallback button title.
    /// @discussion Allows fallback button title customization. A default title "Enter      Password" is used when
    ///             this property is left nil. If set to empty string, the button will be hidden.
    @property (nonatomic, copy) NSString *localizedFallbackTitle;
    

    此代码删除按钮,用户可以使用他们的手指或取消:

    LAContext *context = [[LAContext alloc] init];
    context.localizedFallbackTitle = @"";
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics ...
    
  • 0

    你是对的,在iOS 8中你没有选择将项目存储在Keychain中,只有在成功进行Touch ID身份验证后才能访问它 . iOS 8中添加的 kSecAccessControlUserPresence 访问控制标志使得在Touch ID或Passcode身份验证之后可以访问项目 .

    但现在可以在iOS 9中完成 . 两个与Touch ID相关的标志, kSecAccessControlTouchIDAnykSecAccessControlTouchIDCurrentSethave been added .

    因此,您需要做的就是在为Keychain项创建访问控制对象时使用这两个标志中的任何一个(使用 SecAccessControlCreateWithFlags 函数),并在使用 SecItemAdd 函数添加项时将该对象分配给 kSecAttrAccessControl 属性 .

    an example from Apple证明了这一点;见 addTouchIDItemAsync 方法 .

    有关iOS 9中其他与安全相关的更改的概述,另请参阅this post .

  • 1

    我还没有潜入iOS 8钥匙串,但请记住,4位密码由用户设置 . Apple建议当用户打开TouchID时,他们也会打开更复杂的密码,说"Since security is only as secure as its weakest point, you can choose to increase the security of a 4-digit passcode by using a complex alphanumeric passcode." http://support.apple.com/kb/HT5949

    所以, the user still has the option of using something more complex than a 4-digit passcode . 你不能强迫他们去做 . 如果你真的想强迫它们,听起来你必须放弃Touch ID的便利性 .

相关问题