我正在尝试使用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)
答案 0 :(得分:0)
问题出在我的SecItemUpdate查询中,我不包括访问控制标志。