How to programmatically install a CA Certificate (for EAP WiFi configuration) in Android?

不想你离开。 提交于 2019-12-03 08:16:25

You cannot install it directly since non-system applications don't have access to the key store. On ICS, there is an API for this KeyChain.createInstallIntent() that would launch a system dialog asking the user whether they want to install the certificate. On pre-ICS you can achieve the same thing by launching the install intent using the component name directly (this may or may not work on all devices though). Going through the browser is actually a roundabout way of doing the same thing.

As for your questions:

  1. you cannot specify/force a name. Why do you care about the actual name?
  2. Not really through the browser. If you use the system intent, you can return to your activity and will get a callback if you use startActivityForResult().

Update: Android 4.3 has WifiEnterpriseConfig which both creates a profile and installs keys and certificates in the system credential store. You only need the CHANGE_WIFI_STATE permission.

lonoak

I'm looking for the same... as for your question, @Nikolay:

you cannot specify/force a name. Why do you care about the actual name?

The EAP profile needs the name of the already-installed-CA. If you look at the example in part 4, you can specify:

final String ENTERPRISE_CA_CERT = "";

In the example, the profile does not use the CA name, but that could be the case for other EAP profiles.

I am currently looking to solve the same issues. The best thing that I have found is KeyChain.choosePrivateKeyAlias() allowing the user to select which certificate to use for the SSL. From there you can retrieve the Alias name and pass it to the enterprise wifi configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!