java - How to remove App installed trusted CA cert on uninstalling the App -


i have app gives option install ca cert , gets stored in user tab of trusted credentials , works expected.

fyi (this how install cert):

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); 

if app uninstalled cert remains in trusted credentials.

i cert uninstalled when application uninstalled.

i thought of removing cert using deleteentry method of keystore.

fyi (i haven't tested though.hopefully should work..i update once tested it)

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)                                  }                             }                         }   

even though if consider above code works afaik can't register broadcast receiver uninstallation of own app.

how can go removing cert installed app on uninstallation of app ?

any appreciated !

you cant broadcast of package getting uninstalled own package. may lead inconsistency in system. see answer


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -