Don't migrate in asTunnelConfiguration()

It causes problems when installing a tunnel through a
Configuration Profile on macOS and activating it first through
Network Preferences.

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-02-12 17:37:14 +05:30
parent b5b72b309f
commit 77f929789c
1 changed files with 8 additions and 11 deletions

View File

@ -34,17 +34,14 @@ extension NETunnelProviderProtocol {
} }
func asTunnelConfiguration(called name: String? = nil) -> TunnelConfiguration? { func asTunnelConfiguration(called name: String? = nil) -> TunnelConfiguration? {
migrateConfigurationIfNeeded(called: name ?? "unknown") if let passwordReference = passwordReference,
//TODO: in the case where migrateConfigurationIfNeeded is called by the network extension, let config = Keychain.openReference(called: passwordReference) {
// before the app has started, and when there is, in fact, configuration that needs to be return try? TunnelConfiguration(fromWgQuickConfig: config, called: name)
// put into the keychain, this will generate one new keychain item every time it is started, }
// until finally the app is open. Would it be possible to call saveToPreferences here? Or is if let oldConfig = providerConfiguration?["WgQuickConfig"] as? String {
// that generally not available to network extensions? In which case, what should our return try? TunnelConfiguration(fromWgQuickConfig: oldConfig, called: name)
// behavior be? }
return nil
guard let passwordReference = passwordReference else { return nil }
guard let config = Keychain.openReference(called: passwordReference) else { return nil }
return try? TunnelConfiguration(fromWgQuickConfig: config, called: name)
} }
func destroyConfigurationReference() { func destroyConfigurationReference() {