如何让OpenSSL得到JKS格式的keystore中的public and private key

国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html
内部邀请码:C8E245J (不写邀请码,没有现金送)
国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为“中国PE第一股”,市值超1000亿元。 
------------------------------------------------------------------------------------------------------------------------------------------------------------------

从一个JKS的keystore中导出public key (certificate)

keytool -export -alias mykey -keystore keystore -file exported.crt

转换成PEM格式,这个格式使用更广

openssl x509 -out exported-pem.crt -outform pem -text -in exported.crt -inform der

导出private key(请参考): 下载文件ExportPriv.java,编译后运行

javac ExportPriv.java

java ExportPriv <keystore> <alias> <password> > exported-pkcs8.key

上述得到的private key是PKCS#8 PEM格式,使用如下命令才能转换成apache可以使用的RSA格式

openssl pkcs8 -inform PEM -nocrypt -in exported-pkcs8.key -out exported.key

现在可以把得到的public key(certificate) 和private key打包在一起,转换成windows平台常用的PKCS12格式

openssl pkcs12 -export -out exported.pfx -inkey exported.key -in exported-pem.crt

原文地址:https://www.cnblogs.com/AloneSword/p/3499850.html