Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import key and SSL Certificate into java keystore

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 ?

like image 453
Lolly Avatar asked Dec 14 '25 06:12

Lolly


1 Answers

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

like image 199
Cratylus Avatar answered Dec 16 '25 23:12

Cratylus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!