diff --git a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift index 83c48c9..152d26e 100644 --- a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift +++ b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift @@ -56,21 +56,19 @@ class TunnelsManager { tunnelManager.saveToPreferences { _ in } } #if os(iOS) - let passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil + let verify = true #elseif os(macOS) - let passwordRef: Data? - if proto.providerConfiguration?["UID"] as? uid_t == getuid() { - passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil - } else { - passwordRef = proto.passwordReference // To handle multiple users in macOS, we skip verifying - } + let verify = proto.providerConfiguration?["UID"] as? uid_t == getuid() #else #error("Unimplemented") #endif - if let ref = passwordRef { + if verify && !proto.verifyConfigurationReference() { + wg_log(.error, message: "Unable to verify keychain entry of tunnel: \(tunnelManager.localizedDescription ?? "")") + } + if let ref = proto.passwordReference { refs.insert(ref) } else { - wg_log(.info, message: "Removing orphaned tunnel with non-verifying keychain entry: \(tunnelManager.localizedDescription ?? "")") + wg_log(.error, message: "Removing orphaned tunnel with missing keychain entry: \(tunnelManager.localizedDescription ?? "")") tunnelManager.removeFromPreferences { _ in } tunnelManagers.remove(at: index) }