eap wifi 证书_如何以编程方式安装在Android的CA证书(对于EAP无线网络配置)?

本文探讨了如何在Android应用中程序化安装CA证书并创建EAP Wi-Fi配置。介绍了通过浏览器安装证书的方法及存在的挑战,并提供了从Android 4.3开始使用WifiEnterpriseConfig API直接安装证书和配置文件的方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bd96500e110b49cbb3cd949968f18be7.png

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 programatically 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:

http://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:

The user must name the certificate. This is a challenge because we are adding the WiFi configuration programmitically. Thus we have to ask the user to give the certificate the same name.

The user must enter a password. If they don't have a password set up, the user will create one and enter it twice. If they have set a security password, the user will have to remember that same password and enter it.

Assuming the user successfully completes these steps, he is left hanging in the browser.

This leads to a few questions:

From my app, is there a way to force a name for the certificate that the user installs via the browser?

From my app, is there any way to know when the certificate installation has completed and then give focus back to my app?

Just let me know if you need any clarification.

解决方案

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:

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

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值