Question

HI All,

I have a .crt file and I need to get the associated keystore file. How to do so?

Is keytool is helpful in that?

Thanks.

Was it helpful?

Solution

In JDK8 or higher:

Command below creates empty store and imports your certificate into the keystore:

keytool -import -alias alias -file cert_file.crt -keypass keypass -keystore yourkeystore.jks -storepass Hello1

In JDK7:

Older versions of JDK7 create non-empty keystore which then needs to be cleared. Below is how you do that.

Create store with temporary key inside:

keytool -genkey -alias temp -keystore yourkeystore.jks -storepass Hello1

Then delete existing entry:

keytool -delete -alias temp -keystore yourkeystore.jks -storepass Hello1 

Now you've got empty store. You can check that it's empty:

keytool -list -keystore yourkeystore.jks -storepass Hello1

Then import your certificate to the store:

keytool -import -alias alias -file cert_file.crt -keypass keypass -keystore yourkeystore.jks -storepass Hello1

And off you go!

OTHER TIPS

Yes, for eg.
keytool -genkey -alias duke -keypass dukekeypasswd from (http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/keytool.html)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top