Keychain: Avoid roundtrip via items when accessing item label (stored in kSecAttrLabel)
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
This commit is contained in:
parent
90b41aed89
commit
bcc34e0bb6
|
@ -28,8 +28,9 @@ class Keychain {
|
||||||
if bundleIdentifier.hasSuffix(".network-extension") {
|
if bundleIdentifier.hasSuffix(".network-extension") {
|
||||||
bundleIdentifier.removeLast(".network-extension".count)
|
bundleIdentifier.removeLast(".network-extension".count)
|
||||||
}
|
}
|
||||||
|
let itemLabel = "WireGuard Tunnel: \(name)"
|
||||||
var items: [CFString: Any] = [kSecClass: kSecClassGenericPassword,
|
var items: [CFString: Any] = [kSecClass: kSecClassGenericPassword,
|
||||||
kSecAttrLabel: "WireGuard Tunnel: " + name,
|
kSecAttrLabel: itemLabel,
|
||||||
kSecAttrAccount: name + ": " + UUID().uuidString,
|
kSecAttrAccount: name + ": " + UUID().uuidString,
|
||||||
kSecAttrDescription: "wg-quick(8) config",
|
kSecAttrDescription: "wg-quick(8) config",
|
||||||
kSecAttrService: bundleIdentifier,
|
kSecAttrService: bundleIdentifier,
|
||||||
|
@ -60,9 +61,7 @@ class Keychain {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var access: SecAccess?
|
var access: SecAccess?
|
||||||
ret = SecAccessCreate((items[kSecAttrLabel] as? String)! as CFString,
|
ret = SecAccessCreate(itemLabel as CFString, [extensionApp!, mainApp!] as CFArray, &access)
|
||||||
[extensionApp!, mainApp!] as CFArray,
|
|
||||||
&access)
|
|
||||||
if ret != errSecSuccess || access == nil {
|
if ret != errSecSuccess || access == nil {
|
||||||
wg_log(.error, message: "Unable to create keychain ACL object: \(ret)")
|
wg_log(.error, message: "Unable to create keychain ACL object: \(ret)")
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue