Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am using like below code.
When we use WifiEnterpriseConfig, is enterpriseConfig.setCaCertificate(ca) required? Or is there any way to account for when I manually configure the wifi network via the settings app on an android device, & I choose "use System Certificates" as CA certificate and set the domain to for example "example.org"?
Currently this code crashes the app when executing this code, the network is configured but CA Cert is set to "no validation" and the domain is not set.
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.setEapMethod(WifiEnterpriseConfig.Eap.PEAP);
ec.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAPV2);
ec.setDomainSuffixMatch("example.org");
// How can I set "use system certificates" for:
// ec.setCaCertificate(?); ???
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");
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.