I am trying to connect wpa2 enterprise wifi using iPhone app programmatically.
before that I tried connecting to that wifi manually:
- From Settings in iPhone device
- Used these three parameters SSID, Username, password
- After that it ask to trust the certificate and trusting the certificate, the wifi get connect, Done!
Now I am trying to connect wifi programmatically using following code:
NEHotspotEAPSettings *settings = [[NEHotspotEAPSettings alloc]init];
settings.password = self.password.text;
settings.username = self.username.text;
settings.supportedEAPTypes = [NSArray arrayWithObjects:[NSNumber numberWithInteger:NEHotspotConfigurationEAPTypeEAPPEAP], nil];
NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc]initWithSSID:self.ssid.text eapSettings:settings];
[[NEHotspotConfigurationManager sharedManager]applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@",error.localizedDescription); }
else { NSLog(@“Connected”); }
}];
but this code gives an error
Invalid EAP settings : NEHotspotConfiguration EAP settings must have either trusted server certificates or trusted server names configured
Since I don’t have any trusted server certificate or trusted server name. What should I set in the blow property of NEHotspotEAPSettings (passing nil also gives me same error)
settings.trustedServerNames
Please help to solve this. Thanks!