Connecting to EAP-PEAP Networks via NEHotspotConfigurationManager

I need to programatically connect to a Enterprise Network with security type EAP-PEAP.

NEHotspotEAPSettings *eapSettings = [[NEHotspotEAPSettings alloc] init];
  eapSettings.username = username;
  eapSettings.password = password;
  eapSettings.supportedEAPTypes = [NSArray arrayWithObjects:[NSNumber numberWithInteger:NEHotspotConfigurationEAPTypeEAPPEAP], nil];
  
  //Inner authentication
  eapSettings.ttlsInnerAuthenticationType = NEHotspotConfigurationEAPTTLSInnerAuthenticationMSCHAPv2;
  eapSettings.outerIdentity = @"";

//Server name of the network 
  eapSettings.trustedServerNames = @[@"servername"];
  
  if (@available(iOS 11.0, *)) {
    // Create Hotspot Configuration
    NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid eapSettings:eapSettings];
    NSLog(@"WIFIManager, NEHotspotConfiguration initialized");
    
    [[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) {
      NSLog(@"WIFIManager, NEHotspotConfiguration Configured");
      if (error != nil) {
        NSLog(@"WIFIManager, NEHotspotConfiguration Error: %@", error);
        if (error.code == NEHotspotConfigurationErrorAlreadyAssociated) {
          resolve(@(YES));
        } else {
          reject(@"connection_error", @"Failed to connect to Wi-Fi", error);
        }
      } else {
        resolve(@(YES));
        NSLog(@"WIFIManager, NEHotspotConfiguration Success");
      }
    }];
  }else {
    reject(@"ios_error", @"Not supported in iOS<11.0", nil);

  } }

This is the code I have tried to connect to the network. It is always giving a true-negative result.

As the documentation states, does NEHotspotConfigurationManager supports EAP-PEAP with MSCHAPv2 inner authentication? If it does, is it the correct way of implementing it?

Is there any other way to connect to EAP-PEAP networks using Swift or Objective C?

It is always giving a true-negative result.

What do you mean by that?

I suspect you mean that -applyConfiguration:completionHandler: is calling the completion handle with a non-nil value for error. Is that right?

If so, what do you see when you print the error object?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I mean that applyConfiguration:completionHanlder is calling the completion handle with a nil value for error. But we are not able to connect to the PEAP network via the device. There is no error showing up.

No Information other than the pop up from the System, "Unable to join the network".

Connecting to EAP-PEAP Networks via NEHotspotConfigurationManager
 
 
Q