I know that, to connect to a WiFi network manually, I can do these steps:
- From Settings in iPhone device
- Used these three parameters: SSID, Username, password
- After that it asks to trust the certificate and, after trusting the certificate, the WiFi network gets connected
I am trying to connect programmatically to a WPA2-secured enterprise WiFi network using an iPhone app. Here is my code for this:
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 it gives me 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 below property of NEHotspotEAPSettings (passing nil also gives me same error)?
settings.trustedServerNames
In my Android app, my code is working fine without any certificate; this is specific to iOS.