startVPNTunnel()不';我不能在iOS 14上工作
由于iOS 14发布的startVPNTunnel()已停止工作,且应用程序未创建VPN连接 我的配置如下:startVPNTunnel()不';我不能在iOS 14上工作,ios,swift,vpn,Ios,Swift,Vpn,由于iOS 14发布的startVPNTunnel()已停止工作,且应用程序未创建VPN连接 我的配置如下: private func _save(_ account: VPNServer, completion: VPNConfigureCompletion?) { let keychain = Keychain(service: Bundle.main.bundleIdentifier!) keychain["sharedSecret"]
private func _save(_ account: VPNServer, completion: VPNConfigureCompletion?) {
let keychain = Keychain(service: Bundle.main.bundleIdentifier!)
keychain["sharedSecret"] = account.key
let ikev2Protocol = NEVPNProtocolIKEv2()
ikev2Protocol.useExtendedAuthentication = false
ikev2Protocol.authenticationMethod = .sharedSecret
ikev2Protocol.disconnectOnSleep = false
ikev2Protocol.serverAddress = account.ip
ikev2Protocol.sharedSecretReference = keychain[attributes: "sharedSecret"]?.persistentRef
ikev2Protocol.remoteIdentifier = account.ip
if #available(iOS 13.0, *) {
ikev2Protocol.enableFallback = true
}
vpnManager.protocolConfiguration = ikev2Protocol
vpnManager.isEnabled = true
vpnManager.saveToPreferences { error in
if let err = error {
print("Failed to save profile: \(err.localizedDescription)")
self.delegate?.setConnectionStatus(status: .disconnected)
NotificationCenter.default.post(name: NSNotification.Name.NEVPNStatusDidChange, object: "Failed to save profile")
} else {
completion?()
}
}
}
此代码保存配置,但当您尝试连接时,它会抛出(即使在iPhone设置中手动)。它在iOS 13上运行正常。我们已经尝试使服务器与IPv6兼容,但没有成功。我还尝试添加VPN.IKEv2.ChildSecurityAssociationParameters,但没有成功。
有人有解决办法吗