NEVPNManager stop working with iOS 14 beta. It is trying to connect with VPN and disconnect immediately (I am seeing no error here also). It is working fine till iOS 13.6. I could not able to find any solution why it beehaving like that in iOS 14. Any help will be appriciated.
public func connectIKEv2(config: Configuration,ssidArr: [String], onError: @escaping (String)->Void) {
let p = NEVPNProtocolIKEv2()
if config.pskEnabled {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.certificate
} else {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.none
}
p.serverAddress = config.server
p.disconnectOnSleep = false
p.username = config.account
p.passwordReference = config.getPasswordRef()
p.sharedSecretReference = config.getPSKRef()
p.useExtendedAuthentication = true
p.remoteIdentifier = config.server
p.localIdentifier = config.account
let disconnectRule= NEOnDemandRuleDisconnect()
disconnectRule.ssidMatch = ssidArr
let connectRule = NEOnDemandRuleConnect()
connectRule.interfaceTypeMatch = .any
loadProfile { _ in
self.manager.protocolConfiguration =
if config.onDemand {
self.manager.onDemandRules [disconnectRule,connectRule]
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")
}
}
}
}
}
public func connectIKEv2(config: Configuration,ssidArr: [String], onError: @escaping (String)->Void) {
let p = NEVPNProtocolIKEv2()
if config.pskEnabled {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.certificate
} else {
p.authenticationMethod = NEVPNIKEAuthenticationMethod.none
}
p.serverAddress = config.server
p.disconnectOnSleep = false
p.username = config.account
p.passwordReference = config.getPasswordRef()
p.sharedSecretReference = config.getPSKRef()
p.useExtendedAuthentication = true
p.remoteIdentifier = config.server
p.localIdentifier = config.account
let disconnectRule= NEOnDemandRuleDisconnect()
disconnectRule.ssidMatch = ssidArr
let connectRule = NEOnDemandRuleConnect()
connectRule.interfaceTypeMatch = .any
loadProfile { _ in
self.manager.protocolConfiguration =
if config.onDemand {
self.manager.onDemandRules [disconnectRule,connectRule]
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")
}
}
}
}
}