1

我正在尝试使用 NEVPNManager 以编程方式配置 vpn,并且我成功保存了首选项,但是 当我尝试连接时出现错误“与 VPN 服务器的协商失败” 。在protocolConfiguration 中有什么具体的事情可以让它工作吗?

提前致谢。

4

1 回答 1

0

确保您正确设置 VPN 配置。这是示例代码。

NEVPNProtocolIPSec *protocalConfigurationIPSec = [[NEVPNProtocolIPSec alloc] init]; protocalConfigurationIPSec.username = @"account";

        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;
于 2016-12-01T14:26:31.120 回答