My objective: Create an EAP WiFi configuration - including the CA Certificate - in Android programmitcally.
Problem: How do I install a CA Certificate programmatically (and then reference that certificate in the EAP WiFi configuration)?
I found a very useful link already that allows me to create and save EAP WiFi configurations here: How to programmatically create and read WEP/EAP WiFi configurations in Android?
However this assumes that you have already installed the CA Certificate on the device. I would like to install the certificate within my app - either from the resources in the app, or sent from a server.
Is this even possible? (Rooting is not an option in this case.) If so, how?
Additional info...
I also found a way to add a certificate to a KeyStore: https://stackoverflow.com/a/4490543/1172101
However this is used specifically for creating a secure socket and connecting via HTTPS. I want to use the certificate for WiFi.
Unfortunately, I have yet to find a way to install a CA Certificate programmatically - from within the app.
However, it is possible to install a certificate via the Web browser in Android. Thus, the solution (for now) is to: Launch an intent to open a URL in the Web browser that goes directly to the CA certificate.
This works but there are some challenges:
This leads to a few questions:
Just let me know if you need any clarification.
If a certificate is to be installed for WiFi, first install CA certificate in Settings>Security, then install the WLAN certificate in Settings>Wi-Fi>menu:Advanced>Install certifcates per below: To install a Wi-Fi certificate: Ensure a lock screen PIN or password is set.
Android stores CA certificates in its Java keystore in /system/etc/security/cacerts.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With