Connect WPA2 Enterprise wifi programmatically

I am trying to connect wpa2 enterprise wifi using iPhone app programmatically.

before that I tried connecting to that wifi manually:

  1. From Settings in iPhone device
  2. Used these three parameters SSID, Username, password
  3. 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!

NEHotspotConfigurationManager
is an easy API to use but the details get really gnarly when you start delving into the enterprise configuration side of things. I recommend that you open a DTS tech support incident so that we can talk about this one-on-one.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for the response.

I am not been able to apply for DTS tech support incident. Request you if you can provide any way to solve this here.

Just for more info, our wifi is secured with 802.1x eap.


Thanks

Request you if you can provide any way to solve this here.

Sorry, but no. As I mentioned,

NEHotspotConfigurationManager
gets pretty complex when you start digging into the details, and that’s too complex for me to help in the time that I have available for DevForums.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Hi,

You got this working, I have the same problem

same too, any idea?

If you are experiencing the error for:

Invalid EAP settings : NEHotspotConfiguration EAP settings must have either trusted server certificates or trusted server names configured

Keep in mind that there was some issues here with trustedServerNames and NEHotspotEAPSettings around the iOS 15.0 - 15.2 timeframe. These issues should have been resolve in iOS 15.3.

Connect WPA2 Enterprise wifi programmatically
 
 
Q