Post not yet marked as solved
Post marked as unsolved with 5 replies, 195 views
I'm trying to save a password to the keychain using the kSecAttrAccessControl attribute to control access. This is the code I'm running:
let access = SecAccessControlCreateWithFlags(nil, kSecAttrAccessibleWhenUnlocked, .userPresence, nil)
let attributes = [kSecClass: kSecClassGenericPassword,
kSecAttrService: forPath,
kSecAttrLabel: "My Password",
kSecAttrAccessControl: access as Any,
kSecValueData: password.data(using: .utf8) as Any] as CFDictionary
SecItemAdd(attributes, nil)
The item is being created and I can find it using SecItemCopyMatching but it is not visible in the Keychain Access app.
If I remove kSecAttrAccessControl from the list of attribtues, then the created item is visible in Keychain Access.