【发布时间】:2018-08-18 17:44:28
【问题描述】:
我正在尝试以编程方式使用 iPhone 应用程序连接 wpa2 企业 wifi。
在此之前我尝试手动连接到该 wifi:
- 从 iPhone 设备中的设置
- 使用了SSID、用户名、密码这三个参数
- 请求信任证书并信任证书后,wifi 连接,完成!
现在我正在尝试使用以下代码以编程方式连接 wifi:
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”);
}
}];
但是这段代码出错了
无效的 EAP 设置: NEHotspotConfiguration EAP 设置必须配置受信任的服务器证书或受信任的服务器名称
因为我没有任何受信任的服务器证书或受信任的服务器名称。 我应该在 NEHotspotEAPSettings 的 blow 属性中设置什么(传递 nil 也会给我同样的错误)
settings.trustedServerNames
请帮助解决这个问题。 谢谢!
仅供参考:在没有任何证书的情况下,在 android 应用中运行良好
【问题讨论】:
-
这个问题你解决了吗?我们有同样的问题。
标签: ios objective-c wifi connect