美文网首页
java生成keystore,.crt .key证书导出

java生成keystore,.crt .key证书导出

作者: 黑黑的大猫 | 来源:发表于2019-01-08 10:22 被阅读0次

为完全验证;

最近项目中需要将restful接口统一为https,需要一些证书,如tomcat需要keystore(jks)开启https,有些则需要.crt,.key证书文件。经过一番折腾终于搞定,现将关键步骤记录如下:

1.通过jdk工具生成keystore(jks)文件

设置自签口令

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048

2.转换为p12

输入新密钥库口令(至少6位)

源秘钥库口令若未设置为空,直接回车

输入自签口令(至少6位)

keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12

3.使用openssl命令导出.crt

openssl pkcs12 -in keystore.p12 -nokeys -out my_key_store.crt

4.使用openssl命令导出.key

openssl pkcs12 -in keystore.p12 -nocerts -nodes -out my_store.key

原文:https://blog.csdn.net/u011411069/article/details/79994716

相关文章

网友评论

      本文标题:java生成keystore,.crt .key证书导出

      本文链接:https://www.haomeiwen.com/subject/qucvrqtx.html