我有一个应用程序,可以选择安装CA证书,它被存储在可信凭证的用户选项卡中,它按预期工作。如何删除应用程序安装的可信CA证书在卸载应用程序
FYI(这是我如何安装证书):
Intent installIntent = KeyChain.createInstallIntent();
javax.security.cert.X509Certificate x509 = javax.security.cert.X509Certificate.getInstance(caRootCertBytes);
installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, x509.getEncoded());
installIntent.putExtra(KeyChain.EXTRA_NAME,caRootCertName);
startActivity(installIntent);
如果应用程序是卸载的证书仍然在信任的凭证。
我希望在卸载应用程序时卸载证书。
我想使用deleteEntry方法KeyStore
删除证书。
FYI(我没有测试though.Hopefully应该有一次我测试了它work..I会更新)
javax.security.cert.X509Certificate x509 = javax.security.cert.X509Certificate.getInstance(caRootCertBytes);
KeyStore ks = KeyStore.getInstance("AndroidCAStore")
if (ks != null)
{
ks.load(null, null);
Enumeration<String> aliases = ks.aliases();
while (aliases.hasMoreElements())
{
String alias = (String) aliases.nextElement();
java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate) ks.getCertificate(alias);
String name = x509.getIssuerDN().getName();
if (cert.getIssuerDN().getName().contains(name))
{
ks. deleteEntry(alias)
}
}
}
即使你认为上面的代码虽然工作据我所知,我可以” t注册广播接收器卸载我自己的应用程序。
我该如何去除由我的应用程序在卸载我的应用程序时安装的证书?
任何帮助表示赞赏!
没有办法做到这一点,正是因为卸载过程不是由您的代码处理。这就是Android的设计。你只能希望用户不会忘记明确地做到这一点。 –
@SargeBorsch - Are you sure?..但是keystore提供了一个公共API http://goo.gl/bDbiaI –
据我所知,没有办法从应用程序监听卸载事件。不过,您可以通过定期发送“你在那里?”找到一种方法来保持分析的轨迹。带有推送服务的消息(无应答=卸载逻辑,是的不好)。但仍然无法解决您的移除证书问题。我也想知道是否有这个解决方案 – Ercan