我正在尝试使用NEVPNManager以编程方式配置vpn并且我成功保存首选项,但是当我尝试连接时,我收到错误“与VPN服务器的协商失败”。在protocolConfiguration中有什么特别的东西可以使它工作吗?
提前致谢。
答案 0 :(得分:0)
确保正在正确设置VPN配置。 这是示例代码。
NEVPNProtocolIPSec * protocalConfigurationIPSec = [[NEVPNProtocolIPSec alloc] init]; protocalConfigurationIPSec.username = @" account&#34 ;;
protocalConfigurationIPSec.passwordReference = passwordReference;
protocalConfigurationIPSec.serverAddress = @"ipaddress";
protocalConfigurationIPSec.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;
protocalConfigurationIPSec.sharedSecretReference = sharedSecretReference;
protocalConfigurationIPSec.localIdentifier = @"userGroup"];
protocalConfigurationIPSec.remoteIdentifier = [serverDict objectForKey:@"userGroup";
**protocalConfigurationIPSec.useExtendedAuthentication = YES;**
protocalConfigurationIPSec.disconnectOnSleep = NO;
manager.protocolConfiguration=protocalConfigurationIPSec;
[manager setOnDemandEnabled:NO];
[manager setLocalizedDescription:@"VPN"];
manager.enabled = true;