导出证书一句话解决,可能需要输入密码。
1. 导出证书
keytool -export -alias tomcat -keystore ck.keystore -rfc -file ck.key
导出私钥,一共分三步,中间需要输入密码。
2.导出私钥
2.1 得到pkcs12格式的证书
keytool -importkeystore -srckeystore ck.keystore -destkeystore ck.p12 -deststoretype pkcs12
2.2 转化成pem格式的文件
openssl pkcs12 -in ck.p12 -out ck.pem
2.3 从PEM格式的certificate chain中取出私钥,保存为priv.key
openssl rsa -in priv.key -check
这个命令会输出私钥到标准输出里面,粘贴走就可以啦。
过程并不复杂,参考了很多地方。就不一一列出了。