I am trying to setup a IPSec VPN connection but when I try to run
manager.saveToPreferences
or
manager.loadFromPreferences
The callback functions are never called and so I cannot start the VPN Tunnel, and "123" is never printed. The program just ends. What am I doing wrong?
I am testing this in MacOS 10.13.4
import NetworkExtension
import Foundation
let manager = NEVPNManager.shared()
let p = NEVPNProtocolIPSec()
p.authenticationMethod = NEVPNIKEAuthenticationMethod.sharedSecret
p.remoteIdentifier = remoteID
p.localIdentifier = localID
KeychainWrapper.standard.set("SECRET", forKey: "SECRET")
p.sharedSecretReference = KeychainWrapper.standard.dataRef(forKey: "SECRET");
manager.protocolConfiguration = p
manager.onDemandRules = [NEOnDemandRuleConnect()]
manager.isOnDemandEnabled = true
manager.isEnabled = true
manager.saveToPreferences { completionHandler in
manager.loadFromPreferences { completionHandler in
print(123)
do {
try manager.connection.startVPNTunnel()
} catch (let exception) {
print(exception)
}
}
}
I am also having issues configuring the VPN, but this question is more about why those callbacks never get called.
Also, as a side note. When I run
do {
try manager.connection.startVPNTunnel()
} catch (let exception) {
print(exception)
}
outside of saveToPreferences and loadFromPreferences I get the following error:
Error Domain=NEVPNErrorDomain Code=1 "(null)"
Any help would be greatly appreciate, thanks.