[ad_1]
I am attempt to examine VPN. I take advantage of NEVPNManager, I had related VPN, it really works properly.However Once I need to restrict using proxies for some domains, corresponding to my very own App. I take advantage of NEProxySettings, however it not work, I do not know why.If anybody may help me, I actually recognize it. Let’s suppose my server identify is “www.xxx.com”. Right here is my code:
[self.vpnManager loadFromPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
PSLog(@"%@",error);
return;
}
NEVPNProtocolIKEv2 *vpnProtocollIKEv2 = (NEVPNProtocolIKEv2 *)self.vpnManager.protocolConfiguration;
vpnProtocollIKEv2 = [[NEVPNProtocolIKEv2 alloc] init];
vpnProtocollIKEv2.serverAddress = serviceName;
NEVPNIKEAuthenticationMethod authenticationMethod = [self authenticationMethod:data.authenticationMethod];
vpnProtocollIKEv2.authenticationMethod = authenticationMethod;
if (authenticationMethod == NEVPNIKEAuthenticationMethodCertificate) {
vpnProtocollIKEv2.identityData = [[NSData alloc] initWithBase64EncodedString:p12Base64 choices:NSDataBase64DecodingIgnoreUnknownCharacters];
vpnProtocollIKEv2.identityDataPassword = certificatePassword;
NEProxySettings *proxySettings = [[NEProxySettings alloc] init];
proxySettings.autoProxyConfigurationEnabled = NO;
proxySettings.excludeSimpleHostnames = YES;
proxySettings.HTTPEnabled = YES;
proxySettings.HTTPSEnabled = YES;
proxySettings.exceptionList = @[@"www.xxx.com",@"*.www.xxx.com"];
vpnProtocollIKEv2.proxySettings = proxySettings;
vpnProtocollIKEv2.remoteIdentifier = remoteId;
vpnProtocollIKEv2.localIdentifier = localId;
vpnProtocollIKEv2.disconnectOnSleep = NO;
self.vpnManager.protocolConfiguration = vpnProtocollIKEv2;
[self.vpnManager saveToPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
PSLog(@"%@",error);
}
return;
}
[self startVPNConnect];
}];
}];
[ad_2]
