ios - 使用 biometryCurrentSet iOS 更改指纹后项目不会失效

标签 ios swift security-framework

我正在尝试在设置了 biometryCurrentSet SecAccessControl 标志的钥匙串(keychain)中保存密码。保存和读取工作按预期进行,除非我添加或添加或删除指纹。它仍然返回密码,我预计会出现错误,因为文档指出该项目将无效。 https://developer.apple.com/documentation/security/secaccesscontrolcreateflags/2937192-biometrycurrentset

guard let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, SecAccessControlCreateFlags.biometryCurrentSet, nil) else {
        print("COULD NOT CREATE THE ACCESS CONTROL FLAGS!!!!!")

        return
    }

    guard let pword = password.data(using: String.Encoding.utf8) else {
        print("COULD NOT CREATE THE PASSWORD DATA!!!!!")

        return
    }

    let query: [String : Any] = [kSecClass as String : kSecClassGenericPassword as String,
                                 kSecAttrService as String : service,
                                 kSecAttrAccount as String : username,
                                 kSecAttrAccessControl as String : accessControl,
                                 kSecUseOperationPrompt as String : "Authenticate with biometrics",
                                 kSecUseAuthenticationUI as String : kSecUseAuthenticationUIAllow as String,
                                 kSecValueData as String : pword]

    let status = SecItemAdd(query as CFDictionary, nil)

最佳答案

问题出在我的 SecItemUpdate 查询中,我没有包含访问控制标志。

关于ios - 使用 biometryCurrentSet iOS 更改指纹后项目不会失效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51619208/

相关文章:

ios 使用 NSURLSession 进行 FTP 上传

iphone - iOS:如何在登录后对用户进行身份验证(用于自动登录)?

ios - 无法让 UITableViewController 动态填充

swift - 在 Swift 类之间共享数据

xml - 将 XML 元素存储在字符串中

ios - 如何实现自动填充凭据提供程序扩展 - iOS 11,swift4

ios - 在 OS X 上登录,在 iOS 和 OSStatus 上验证 -9809

ios - UIWebViewDelegate:页面内导航期间未调用 webViewDidFinishLoad

ios - 以米为单位的自定义 MKOverlay

ios - SecAddItem 只返回 errSecParam,不管我做什么