Import key and SSL Certificate into java keystore

老子叫甜甜 提交于 2019-12-10 10:28:45

问题


I have certificate file and private key file in pem format. Is it possible to load these files into Java keystore using Java code with default libraries that comes with JDK and not with third party libraries. When I tried googling, I am able to find only files which are in .der format to import into java keystore using java code.

http://knowledge-oracle.blogspot.in/2009/02/import-private-key-and-certificate-in.html

Is it possible to load key and certificate file which is in pem format into java keystore through java code without converting to .der format ?


回答1:


It is possible but not without using third-party libraries.
Java does not use pem format for keystore containers as OpenSSL does so you will have to convert these into a keystore either PKCS12 or JKS.
You can do the conversion by code using bouncy castle or you could use a tool to create a keystore from the pem file and use the keystore in your application.
Try this java application Certificate Helper to do the conversion to keystore




回答2:


Here is a small utility program what can import pem files: http://www.clearfield.com/key_store_browser/key_store_browser.html

This utility is opensource, you can download the source code.



来源:https://stackoverflow.com/questions/14398423/import-key-and-ssl-certificate-into-java-keystore

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