证书生成(keystore、truststore、crt、key)

本文详细介绍了如何使用keytool和openssl生成keystore、truststore、.crt及.key等证书文件的过程。从生成keystore开始,逐步介绍了导出公钥证书、生成信任存储、转换keystore为p12格式、以及使用openssl生成.crt和.key文件的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.说明

        keystore和truststore通过jdk的keytool生成即可;.crt和.key生成需要使用openssl。

2.生成keystore

keytool -genkeypair -alias certificatekey -keyalg RSA -validity 365 -keystore tomcat.keystore

        输入2次自定义密钥库口令123456,记住该口令

        在OpenSSL的bin里面找到tomcat.keystore

3.导出公钥证书cer

keytool -export -alias certificatekey -keystore tomcat.keystore -rfc -file tomcat.cer

        执行命令,输入前面自定义的密钥库口令123456 


4.生成truststore

Keytool -import -alias certificatekey -file tomcat.cer -keystore tomcat.truststore

5.keystore转换为p12

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

6.使用openssl生成.crt

        openssl下载路径:

Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions

/index.html

OpenSSL-Win32-桌面系统文档类资源-CSDN下载(win10以下)

下载OpenSSL-Win32.rar,解压到c盘,进入到bin路径下;将第5步生成的tomcat.p12文件复制到这个路径下。

        执行下面命令,生成tomcat.crt。

openssl pkcs12 -in tomcat.p12 -nokeys -out tomcat.crt

7.使用openssl生成.key

openssl pkcs12 -in tomcat.p12 -nocerts -nodes -out tomcat.key

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kenick

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值