如何在 Android 10 (Android Q) 或更高版本上连接到经过半径验证的 Wifi 设备

问题描述

我正在创建一个到经过 Radius 身份验证的 Wifi 设备的连接过程。

我尝试根据各种文章进行连接,但没有成功。

我通过以下设置确认了手动连接。

・第 2 阶段认证:MSCHAPV2

・CA 证书:使用系统证书

・域:域字符串

・ID:ID字符串

・密码:密码字符串

Logcat 在 addNetworkSuggestions 期间显示“企业配置不安全”。

Wifi连接处理部分代码如下。

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

WifiConfiguration targetConfig = new WifiConfiguration();
targetConfig.SSID = '"' + targetSSID + '"';
targetConfig.allowedKeyManagement.clear();
targetConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
targetConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
WifiEnterpriseConfig ec = new WifiEnterpriseConfig();
ec.setIdentity(userName);
ec.setPassword(password);
ec.setDomainSuffixMatch("domain.name");
ec.setEapMethod(WifiEnterpriseConfig.Eap.PEAP);
ec.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAPV2);
targetConfig.enterpriseConfig = ec;

final WifiNetworkSuggestion suggestion1 =
        new WifiNetworkSuggestion.Builder()
                .setSsid(targetSSID)
                .setWpa2Passphrase(password)
                .setWpa2EnterpriseConfig(targetConfig.enterpriseConfig)
                .setIsAppInteractionrequired(true)
                .build();

final List<WifiNetworkSuggestion> list = new ArrayList<>();
list.add(suggestion1);
int result = wifiManager.addNetworkSuggestions(list);

if (result == WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS) {
    Log.d("testLog","success");
} else {
    Log.d("testLog","Failed");
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)