aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-06 02:01:12 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-06 06:20:23 +0100
commited8dc516dc5aa5b47afec780a69f4a8176e57500 (patch)
tree2b89fe0412262dd23215e1080665229fac93d43e /WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
parentKeychain: store configurations in keychain instead of providerConfig (diff)
downloadwireguard-apple-ed8dc516dc5aa5b47afec780a69f4a8176e57500.tar.xz
wireguard-apple-ed8dc516dc5aa5b47afec780a69f4a8176e57500.zip
LegacyConfig: Remove and support plaintext for .mobileconfig
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift')
-rw-r--r--WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift13
1 files changed, 13 insertions, 0 deletions
diff --git a/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
index 3b7cd1e0..bdc17ac0 100644
--- a/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
+++ b/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
@@ -56,4 +56,17 @@ extension NETunnelProviderProtocol {
guard let ref = passwordReference else { return nil }
return Keychain.verifyReference(called: ref) ? ref : nil
}
+
+ @discardableResult
+ func migrateConfigurationIfNeeded(called name: String) -> Bool {
+ /* This is how we did things before we switched to putting items
+ * in the keychain. But it's still useful to keep the migration
+ * around so that .mobileconfig files are easier.
+ */
+ guard let oldConfig = providerConfiguration?["WgQuickConfig"] as? String else { return false }
+ providerConfiguration = nil
+ guard passwordReference == nil else { return true }
+ passwordReference = Keychain.makeReference(containing: oldConfig, called: name)
+ return true
+ }
}