Can i get installed certificate on my system through java

不羁岁月 提交于 2019-12-01 05:30:24

问题


Can i get installed certificates on my system through java

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

Is there is some api available for this????


回答1:


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

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




回答2:


This depends on the system. Windows has centralized certificate storage, while other platforms don't (at least, no uniform one). So querying system certificates is platform-specific. And as it is, it would be wise to look for JNI to platform-specific API for doing what you need.

I guess there must be some class already available for Windows (most likely working via JNI), but I never saw one. I'd be interested in such solution too (for specific purposes where JNI can't be used).



来源:https://stackoverflow.com/questions/3325535/can-i-get-installed-certificate-on-my-system-through-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!