首页 文章

以编程方式连接WPA2 Enterprise wifi

提问于
浏览
0

我正在尝试以编程方式使用iPhone应用程序连接wpa2企业wifi .

before that I tried connecting to that wifi manually:

  • 来自iPhone设备的设置

  • 使用了这三个参数SSID,用户名,密码

  • 之后它要求信任证书并信任证书,wifi连接,完成!

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

无效的EAP设置:NEHotspotConfiguration EAP设置必须配置可信服务器证书或可信服务器名称

由于我没有任何可信服务器证书或可信服务器名称 . 我应该在NEHotspotEAPSettings的打击属性中设置什么(传递nil也给我同样的错误)

settings.trustedServerNames

请帮忙解决这个问题 . 谢谢!

仅供参考:在Android应用程序中工作正常,没有任何证书

1 回答

相关问题