Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NEVPNProtocolIPSec *p = (NEVPNProtocolIPSec*)_vpnManager.protocol;
- if (!p) {
- p = [[NEVPNProtocolIPSec alloc] init];
- }
- p.username = _ID;
- p.serverAddress = _server;
- //p.serverCertificateIssuerCommonName = @"COMODO RSA Domain Validation Secure Server CA";
- p.remoteIdentifier = remoteID;//@"hide.me";
- p.passwordReference = [self searchKeychainCopyMatching:VPN_PwdIdentifier];
- p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;//NEVPNIKEAuthenticationMethodSharedSecret;
- p.sharedSecretReference = [self searchKeychainCopyMatching:VPN_PrivateKeyIdentifier];
- p.useExtendedAuthentication = YES;
- p.disconnectOnSleep = NO;
- _vpnManager.protocol = p;
- _vpnManager.onDemandEnabled=YES;
- _vpnManager.localizedDescription = _vpnTitle?_vpnTitle:@"Ipsec Test"; //设置VPN的名字 可以自定义
- // 保存设置
- [_vpnManager saveToPreferencesWithCompletionHandler:^(NSError *error) {
- if(error) {
- completeHandle(NO,[NSString stringWithFormat:@"Save config failed [%@]", error.localizedDescription]);
- }
- else {
- completeHandle(YES,@"Save config success");
- }
- }];
Advertisement
Add Comment
Please, Sign In to add comment