1

我正在尝试在设置了 biometryCurrentSet SecAccessControl 标志的钥匙串中保存密码。按预期保存和读取工作,除非我添加或添加或删除指纹。它仍然返回密码,我期待一个错误,因为文档指出该项目将失效。 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)
4

1 回答 1

1

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

于 2018-07-31T18:56:03.567 回答