I'm trying to run my VPN iOS application on Mac OS platform with Mac Catalyst.
My code is work on iOS applications but somehow it's not working on Mac OS.
VPN is not connect. But seems available in Network from System Preferences on Mac Catalina.
And also its contains our VPN connection informations such as server name, password. These all correct. In Keychain I would see psk and password. As far as I know psk is a shared secret key. But If I click to connect from network part I encounter with no shared secret key provided error. But actually its stored in keychain access.
My connection type is IPSec.
In Xcode After that clicked to connect VPN button I would see
Failed to copy content, SecKeychainItemCopyContent returned The contents of this item cannot be retrieved error< in console
I put that my connection part here.But to remind my code works without any mistake on iOS applications. Same code not works on Mac OS as well. Thats the problem.
Any help would be great!
public func connectIKEv2(config: Configuration, onError: @escaping (String)->Void) {
let p = NEVPNProtocolIPSec()
if config.pskEnabled {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.sharedSecret
} else {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.none
}
p.serverAddress = config.server
p.disconnectOnSleep = false
p.username = config.account
p.passwordReference = config.getPasswordRef()
p.sharedSecretReference = config.getPSKRef()
// I catch password and psk without no mistake.
p.useExtendedAuthentication = true
// two lines bellow may depend of your server configuration
p.remoteIdentifier = config.server
// p.localIdentifier = config.account
loadProfile { _ in
self.manager.protocolConfiguration = p
if config.onDemand {
self.manager.onDemandRules = [NEOnDemandRuleConnect()]
self.manager.isOnDemandEnabled = true
}
self.manager.isEnabled = true
self.saveProfile { success in
if !success {
onError("Unable to save vpn profile")
return
}
self.loadProfile() { success in
if !success {
onError("Unable to load profile")
return
}
let result = self.startVPNTunnel()
if !result {
onError("Can't connect")
}
}
}
}
}