开发者

JAVA: how to obtain keystore file for a certification (crt) file

开发者 https://www.devze.com 2023-01-22 04:59 出处:网络
HI All, I have a .crt file and I need to get the associated keystore file. How to do开发者_如何转开发 so?

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.


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!


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号