Keychain: Enable correct keychain sharing in macOS

To enable sharing of keychain items using access groups in macOS,
the kSecUseDataProtectionKeychain attribute should be set.
This key has effect only in macOS, and is unavailable in iOS 12,
so we set it only in macOS.
This commit is contained in:
Roopesh Chander 2021-02-08 00:41:46 +05:30 committed by Davide De Rosa
parent 123f4d658e
commit 433e3f8dc9
1 changed files with 3 additions and 0 deletions

View File

@ -320,6 +320,9 @@ public class Keychain {
private func setScope(query: inout [String: Any], context: String?) {
if let accessGroup = accessGroup {
query[kSecAttrAccessGroup as String] = accessGroup
#if os(macOS)
query[kSecUseDataProtectionKeychain as String] = true
#endif
}
if let context = context {
query[kSecAttrService as String] = context