Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert .cer certificate to .jks

I need to convert a .cer file to a .jks file. I saw a few questions about it, but haven't seen a solution to what I need.

I don't need it in order to add it to my local certificates, but as a file to upload to a server. I also need to do it only once, and not programmatically. There's this thread Converting .cer to .jks using java and the author says he had done it successfully, but I couldn't comment to his last reply as I don't have enough reputation, nor could I send him a personal message and ask him.

So if anyone knows of a simple way to do so, I'll be glad to hear.

like image 739
arikabc Avatar asked May 20 '15 14:05

arikabc


People also ask

Can we convert CER to PEM?

pem is the name of the security certificate you want to convert in CER format, and cert. cer is the name of the certificate after conversion. This is how you can convert a CER file to PEM using the OpenSSL utility.

What is .JKS certificate?

A Java keystore (JKS) file is a secure file format used to hold certificate information for Java applications.


2 Answers

keytool comes with the JDK installation (in the bin folder):

keytool -importcert -file "your.cer" -keystore your.jks -alias "<anything>" 

This will create a new keystore and add just your certificate to it.

So, you can't convert a certificate to a keystore: you add a certificate to a keystore.

like image 189
David Lavender Avatar answered Sep 28 '22 01:09

David Lavender


Just to be sure that this is really the "conversion" you need, please note that jks files are keystores, a file format used to store more than one certificate and allows you to retrieve them programmatically using the Java security API, it's not a one-to-one conversion between equivalent formats.

So, if you just want to import that certificate in a new ad-hoc keystore you can do it with Keystore Explorer, a graphical tool. You'll be able to modify the keystore and the certificates contained therein like you would have done with the java terminal utilities like keytool (but in a more accessible way).

like image 41
uraimo Avatar answered Sep 28 '22 00:09

uraimo