所以我正在尝试使用 NEVPNManager 以编程方式设置我的 VPN。我被困在配置上,真的很困惑去哪里。
sharedSecretReference 真的让我大吃一惊。我在其他地方看到过说我需要使用钥匙串的事情,但是如何以及为什么。我可以手动使用大约 6 个选项连接到这个 VPN,所以我为什么需要这么多。
如果您发现其他任何我可能做错的事情,请告诉我。这是我目前使用的确切代码
NEVPNProtocolIPSec *p = [[NEVPNProtocolIPSec alloc] init];
p.username = [config objectForKey: @"username"];
p.passwordReference = [config objectForKey: @"password"];
p.serverAddress = [config objectForKey: @"ip"];
p.localIdentifier = [config objectForKey: @"vpn"];
p.remoteIdentifier = [config objectForKey: @"vpn"];
p.useExtendedAuthentication = NO;
p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;
p.disconnectOnSleep = NO;
p.sharedSecretReference = [config objectForKey: @"psk"];