Guest User

IKEV2

a guest
Apr 10th, 2017
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NEVPNProtocolIPSec *p = (NEVPNProtocolIPSec*)_vpnManager.protocol;
  2.             if (!p) {
  3.                 p = [[NEVPNProtocolIPSec alloc] init];
  4.             }
  5.            
  6.             p.username = _ID;
  7.             p.serverAddress = _server;
  8.             //p.serverCertificateIssuerCommonName = @"COMODO RSA Domain Validation Secure Server CA";
  9.             p.remoteIdentifier = remoteID;//@"hide.me";
  10.             p.passwordReference = [self searchKeychainCopyMatching:VPN_PwdIdentifier];
  11.             p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;//NEVPNIKEAuthenticationMethodSharedSecret;
  12.             p.sharedSecretReference = [self searchKeychainCopyMatching:VPN_PrivateKeyIdentifier];
  13.             p.useExtendedAuthentication = YES;
  14.             p.disconnectOnSleep = NO;
  15.            
  16.             _vpnManager.protocol = p;
  17.             _vpnManager.onDemandEnabled=YES;
  18.             _vpnManager.localizedDescription = _vpnTitle?_vpnTitle:@"Ipsec Test"; //设置VPN的名字 可以自定义
  19.            
  20.             // 保存设置
  21.             [_vpnManager saveToPreferencesWithCompletionHandler:^(NSError *error) {
  22.                 if(error) {
  23.                     completeHandle(NO,[NSString stringWithFormat:@"Save config failed [%@]", error.localizedDescription]);
  24.                 }
  25.                 else {
  26.                     completeHandle(YES,@"Save config success");
  27.                 }
  28.             }];
Advertisement
Add Comment
Please, Sign In to add comment