如何使用keytool创建证书链? [英] How to create a certificate chain using keytool?
本文介绍了如何使用keytool创建证书链?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要在Java中创建证书链,如下所示:
I want to create certificate chain in java as follows:
ca.mycompany.com
|--asia.mycompany.com
|--india.mycompany.com
其中ca.mycompany.com是根证书(自签名).
where ca.mycompany.com is a root certificate (self signed).
我知道OpenSSL可以做到.但是可以使用keytool来实现吗?
I know this is possible with OpenSSL. But is it possible to to achieve this with keytool?
如果没有,我可以使用Mozilla NSS库实现吗?
If not, can I achieve this with Mozilla NSS library?
推荐答案
There is an example in the keytool documentation that shows how to do this:
keytool -genkeypair -keystore root.jks -alias root -ext bc:c
keytool -genkeypair -keystore ca.jks -alias ca -ext bc:c
keytool -genkeypair -keystore server.jks -alias server
keytool -keystore root.jks -alias root -exportcert -rfc > root.pem
keytool -storepass <storepass> -keystore ca.jks -certreq -alias ca | keytool -storepass <storepass> -keystore root.jks -gencert -alias root -ext BC=0 -rfc > ca.pem
cat root.pem ca.pem > cachain.pem
keytool -keystore ca.jks -importcert -alias ca -file cachain.pem
keytool -storepass <storepass> -keystore server.jks -certreq -alias server | keytool -storepass <storepass> -keystore ca.jks -gencert -alias ca -ext ku:c=dig,keyEncipherment -rfc > server.pem
cat root.pem ca.pem server.pem > serverchain.pem
keytool -keystore server.jks -importcert -alias server -file serverchain.pem
您还可以使用 KeyStore Explorer 轻松生成证书链:
You can also generate certificate chains pretty easily with KeyStore Explorer:
- 创建一个新的密钥对,这意味着创建一个自签名证书(根CA).
- 右键单击根CA证书,然后选择签名新密钥对",这将创建子CA证书和密钥对.
- 右键单击子CA证书,然后再次选择签署新密钥对".
生成的链:
这篇关于如何使用keytool创建证书链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文