NEHotspotConfigurationErrorDomain代码= 4“无效的EAP设置”

时间:2018-10-09 04:14:42

标签: ios swift nehotspothelper

我在iOS 11 iPhone上使用NEHotspotConfigurationManager来连接到使用WPA2企业版的特定Wi-Fi网络。 将证书保存到钥匙串并从钥匙串检索可以正常工作。

代码如下:

let config = NEHotspotConfiguration(ssid: self.ssid)
let settings = NEHotspotEAPSettings() 
// settings.isTLSClientCertificateRequired = true 

settings.password = "********" 
settings.username = "********" 
settings.supportedEAPTypes = [NSNumber.init(value: 
NEHotspotEAPSettings.EAPType.EAPPEAP.rawValue)] 

let getquery: [String: Any] = [kSecClass as String: 
kSecClassCertificate, 
kSecAttrLabel as String: "myCert", 
kSecReturnRef as String: kCFBooleanTrue] 

var item: CFTypeRef? 
let status = SecItemCopyMatching(getquery as CFDictionary, &item) 
if status == errSecSuccess { 
  if let certificate = item as! SecCertificate? { 
    if settings.setTrustedServerCertificates([certificate]) { 
       print("completed setTrustedServerCertificates successfully 
    } 
  } 
} else { 
  print("failed to retrieve \(status)") 
} 
config = NEHotspotConfiguration(ssid: "My wifi", eapSettings: settings) 





func add(network: Network, completion: @escaping (Error?) -> Void) { 
    self.manager.apply(network.configuration) { (error) in 
    assert(Thread.isMainThread) 
    self.startUpdate() 
    completion(error) 
  } 
// Start an update now. The comments associated with `refresh()` explain 
// why I do this. 
self.startUpdate() 
} 

注意:我能够为WPA2建立Wifi连接,而没有任何麻烦。

问题是:配置中出了什么问题?为什么会提示我“无效的EAP设置”错误,如何解决?

0 个答案:

没有答案