简体   繁体   English

JAVA:如何获取认证(crt)文件的密钥库文件

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

HI All, 大家好,

I have a .crt file and I need to get the associated keystore file. 我有一个.crt文件,我需要获取相关的密钥库文件。 How to do so? 怎么办?

Is keytool is helpful in that? keytool有用吗?

Thanks. 谢谢。

In JDK8 or higher: 在JDK8或更高版本中:

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: 在JDK7中:

Older versions of JDK7 create non-empty keystore which then needs to be cleared. 旧版本的JDK7创建非空密钥库,然后需要将其清除。 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) keytool -genkey -alias duke -keypass dukekeypasswd来自(http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/keytool.html)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM