在Android 10+上连接企业WPA2 wifi

3
我正在尝试使用Kotlin本地代码在Flutter上创建企业级WPA2连接。我正在使用WifiSuggestion API,因为我希望在应用程序关闭后wifi仍然保持连接。以下是实现方式:
            val enterpriseConfig = WifiEnterpriseConfig()

            enterpriseConfig.identity = uid
            enterpriseConfig.password = uPassword
            enterpriseConfig.eapMethod = WifiEnterpriseConfig.Eap.PEAP
            enterpriseConfig.phase2Method = WifiEnterpriseConfig.Phase2.MSCHAPV2

            val eduroamSuggestion = WifiNetworkSuggestion.Builder()
                    .setSsid(wifiSSID)
                    .setWpa2EnterpriseConfig(enterpriseConfig)
                    .build()

我遇到了java.lang.IllegalArgumentException: Enterprise configuration is insecure错误,如下面的堆栈跟踪所示。

E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612): Failed to handle method call
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612): java.lang.IllegalArgumentException: Enterprise configuration is insecure
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at android.net.wifi.WifiNetworkSuggestion$Builder.setWpa2EnterpriseConfig(WifiNetworkSuggestion.java:271)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at br.uff.uffmobileplus.WifiHandler$Companion.assembleConnection(WifiHandler.kt:171)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at br.uff.uffmobileplus.MainActivity.configureFlutterEngine$lambda-0(MainActivity.kt:59)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at br.uff.uffmobileplus.MainActivity.lambda$1vo85UVy1PXOPIbKlJk84gSeKS4(Unknown Source:0)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at br.uff.uffmobileplus.-$$Lambda$MainActivity$1vo85UVy1PXOPIbKlJk84gSeKS4.onMethodCall(Unknown Source:2)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$AIEPqY6mWzaNK15HekX9bftoAXs.run(Unknown Source:12)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at android.os.Looper.loop(Looper.java:236)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at android.app.ActivityThread.main(ActivityThread.java:8037)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/MethodChannel#br.uff.uffmobileplus/uffmobile_channel(11612):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
1个回答

3

Android源代码中有答案。当WifiEnterpriseConfig.isInsecure()评估为true时,会出现错误消息

对于您的情况,您需要:

  • 添加enterpriseConfig.DomainSuffixMatchenterpriseConfig.AltSubjectMatch之一,以及
  • 根据环境,我认为您可能需要通过enterpriseConfig.CaCertificate添加RADIUS服务器的CA证书。

对于用户名/密码验证,验证RADIUS服务器的证书非常重要。否则,客户端将向设置了SSID“eduroam”的攻击者发送凭据。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接