Search code examples
javalinuxcertificatessl-certificatekeystore

How to list all SSL/TLS certificates programmatically in Linux?


To load the certificates in Windows I use:

KeyStore keystore = KeyStore.getInstance("WINDOWS-ROOT"); //and WINDOWS-MY
keystore.load(null, null);
// here operations to make the list

in Android:

KeyStore keystore = KeyStore.getInstance("AndroidCAStore");
keystore.load(null, null);
// here operations to make the list

How can I do that in linux? If it can't be done in Linux with this API how can I do it in another way?


Solution

  • You can find them under /etc/ssl/certs. Simply do a ls -l tells you more.

    ls -l /etc/ssl/certs/
    

    They are all in .pem or .crt. Easy to read using java.io.File objects to read. You need a loop to read them all.