Fix macOS demo not connecting

Missing keychain sharing capabilities.
This commit is contained in:
Davide De Rosa 2021-11-02 22:22:04 +01:00
parent 92fd620771
commit d977c3317c
4 changed files with 46 additions and 38 deletions

View File

@ -143,24 +143,24 @@ class ViewController: UIViewController, URLSessionDataDelegate {
}
private func testFetchRef() {
// let keychain = Keychain(group: ViewController.APP_GROUP)
// let username = "foo"
// let password = "bar"
//
// guard let _ = try? keychain.set(password: password, for: username) else {
// print("Couldn't set password")
// return
// }
// guard let passwordReference = try? keychain.passwordReference(for: username) else {
// print("Couldn't get password reference")
// return
// }
// guard let fetchedPassword = try? Keychain.password(for: username, reference: passwordReference) else {
// print("Couldn't fetch password")
// return
// }
//
// print("\(username) -> \(password)")
// print("\(username) -> \(fetchedPassword)")
let keychain = Keychain(group: appGroup)
let username = "foo"
let password = "bar"
guard let _ = try? keychain.set(password: password, for: username, context: tunnelIdentifier) else {
print("Couldn't set password")
return
}
guard let passwordReference = try? keychain.passwordReference(for: username, context: tunnelIdentifier) else {
print("Couldn't get password reference")
return
}
guard let fetchedPassword = try? keychain.password(for: username, reference: passwordReference, context: tunnelIdentifier) else {
print("Couldn't fetch password")
return
}
print("\(username) -> \(password)")
print("\(username) -> \(fetchedPassword)")
}
}

View File

@ -14,5 +14,9 @@
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)group.com.algoritmico.TunnelKit.Demo</string>
</array>
</dict>
</plist>

View File

@ -14,5 +14,9 @@
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)group.com.algoritmico.TunnelKit.Demo</string>
</array>
</dict>
</plist>

View File

@ -128,25 +128,25 @@ class ViewController: NSViewController {
}
private func testFetchRef() {
// let keychain = Keychain(group: ViewController.APP_GROUP)
// let username = "foo"
// let password = "bar"
//
// guard let _ = try? keychain.set(password: password, for: username) else {
// print("Couldn't set password")
// return
// }
// guard let passwordReference = try? keychain.passwordReference(for: username) else {
// print("Couldn't get password reference")
// return
// }
// guard let fetchedPassword = try? Keychain.password(for: username, reference: passwordReference) else {
// print("Couldn't fetch password")
// return
// }
//
// print("\(username) -> \(password)")
// print("\(username) -> \(fetchedPassword)")
let keychain = Keychain(group: appGroup)
let username = "foo"
let password = "bar"
guard let _ = try? keychain.set(password: password, for: username, context: tunnelIdentifier) else {
print("Couldn't set password")
return
}
guard let passwordReference = try? keychain.passwordReference(for: username, context: tunnelIdentifier) else {
print("Couldn't get password reference")
return
}
guard let fetchedPassword = try? keychain.password(for: username, reference: passwordReference, context: tunnelIdentifier) else {
print("Couldn't fetch password")
return
}
print("\(username) -> \(password)")
print("\(username) -> \(fetchedPassword)")
}
}