Can I get the installed certificate on my system through java

Can I get installed certificates on my system through java

something like that. Certificate [] certificate = someClass.getsystemCertificates ();

Are there any api for this?

+4
source share
2 answers

You can use the keytool command to get a list of certificates in your cacerts file, which is a collection of approved certificates that Java ships with. The default password for this keystore is "changeit".

keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit

+2
source

It depends on the system. Windows has a centralized certificate store, but on other platforms there is no (at least there is no single). Therefore, requesting system certificates is platform dependent. And be that as it may, it would be prudent to look for the JNI for the platform specific API in order to do what you need.

I assume that for Windows there is already a class that most likely works through JNI, but I have never seen it. I will also be interested in such a solution (for specific purposes, when JNI cannot be used).

+1
source

All Articles