admin管理员组文章数量:1538180
各类证书由于存储的内容不同(如是否包含公钥/私钥是否加密存储/单一证书或多证书等)、采用编码不同(DER/BASE64)、标准不同(如PEM/PKCS),所以尽管X.509标准规定了证书内容规范,但证书文件还是五花八门。好在openssl对这些不同的标准都有着不错的支持,可以用来进行不同格式证书的转换。
大体来说,证书转换要作的工作有这么几种
编码转换:DER<-->BASE64
不同证书标准的转换:PKCS系列<-->PEM/CER
私钥的增/减/提取/转换
...
PEM--DER/CER(BASE64--DER编码的转换)
openssl x509 -outform der -in certificate.pem -out certificate.derPEM--P7B(PEM--PKCS#7)
openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cerPEM--PFX(PEM--PKCS#12)
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crtPEM--p12(PEM--PKCS#12)
openssl pkcs12 -export -out Cert.p12 -in Cert.pem -inkey key.pemCER/DER--PEM(编码DER--BASE64)
openssl x509 -inform der -in certificate.cer -out certificate.pemP7B--PEM(PKCS#7--PEM)
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cerP7B--PFX(PKCS#7--PKCS#12)
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.ceropenssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer
PFX/p12--PEM(PKCS#12--PEM)
openssl pkcs12 -in certificate.pfx -out certificate.cer如无需加密pem中私钥,可以添加选项-nodes;
如无需导出私钥,可以添加选项-nokeys;
PEM BASE64--X.509文本格式
openssl x509 -in Key.pem -text -out Cert.pemPFX文件中提取私钥(.key)
openssl pkcs12 -in mycert.pfx -nocerts -nodes -out mycert.keyPEM--SPC
openssl crl2pkcs7 -nocrl -certfile venus.pem -outform DER -out venus.spcPEM--PVK(openssl 1.x开始支持)
openssl rsa -in mycert.pem -outform PVK -pvk-strong -out mypvk.pvkPEM--PVK(对于openssl 1.x之前的版本,可以下载pvk转换器后通过以下命令完成)
pvk -in ca.key -out ca.pvk -nocrypt -topvkPVK格式更多参考:http://www.drh-consultancy.demon.co.uk/pvk.html
openssl更多选项及功能,请参考openssl手册
版权声明:本文标题:使用openssl进行证书格式转换 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726968634a1092504.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论