我正在尝试用Kotlin本地代码创建一个企业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:企业配置是不安全的错误,如下面的堆栈跟踪所示
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)发布于 2022-07-05 12:23:48
Android源代码掌握着答案。当出现错误消息 ()计算为true时,您的WifiEnterpriseConfig.isInsecure。
对于你的案子,你
enterpriseConfig.DomainSuffixMatch或enterpriseConfig.AltSubjectMatch,并且enterpriseConfig.CaCertificate添加RADIUS服务器的CA证书。对于用户名/密码身份验证,重要的是验证RADIUS服务器的证书。否则,客户端将向使用SSID "eduroam“设置WiFi的攻击者发送凭据。
https://stackoverflow.com/questions/71788136
复制相似问题