Hi,

I am able to read the certificates in system/etc/security/cacerts.bks
using the following code. I installed a .p12 certificate from the SD
card but the installed certificate is not getting listed with the same
code. I guess cacerts.bks doesn't get updated when a new certificate
is installed from SD card. if it is not in cacerts.bks, then in which
key store the certificate is getting installed and how to read that
through a program. Following is the code for listing the certificates
from cacerts.bks.

KeyStore smartCardKeyStore = KeyStore.getInstance("BKS");
String fileName = "system/etc/security/cacerts.bks";
FileInputStream stream = new FileInputStream(new File(fileName));


            smartCardKeyStore.load(stream, "changeit".toCharArray());
            //Get the enumeration of the entris in the keystore
            Enumeration aliasesEnum = smartCardKeyStore.aliases();
            while (aliasesEnum.hasMoreElements()) {

                //Print alias
                String alias = (String) aliasesEnum.nextElement();
                System.out.println("Alias: " + alias);
                //Print certificate
                X509Certificate cert = (X509Certificate)
smartCardKeyStore.getCertificate(alias);
                System.out.println("Certificate: " + cert);
                 }

-- 
You received this message because you are subscribed to the Google Groups 
"Android Security Discussions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-security-discuss?hl=en.

Reply via email to