SSL证书其他格式转换为PEM格式的方法
2022年5月30日
在不同服务器上安装SSL证书,所要求的格式也不一样。本文主要来介绍一下将SSL证书其他格式转换为PEM格式的方法。
1、CER/CRT转换为PEM
将“cert.crt”证书文件直接重命名为“cert.pem”
2、PFX转换为PEM
1)提取私钥命令,以“cert.pfx”转换为“key.pem”为例
openssl pkcs12 -in cert.pfx -nocerts -out key.pem
2)提取证书命令,以“cert.pfx”转换位“cert.pem”为例
openssl pkcs12 -in cert.pfx -nokeys -out cert.pem
3、P7B转换为PEM
1)证书转换,以“cert.p7b”转换为“cert.cer”为例
openssl pkcs7 -print_certs -in cert.p7b -out cert.cer
2)将“cert.cer”证书文件直接重命名为“cert.pem”
4、DER转换为PEM
1)提取私钥命令,以“privatekey.der”转换为“privatekey.pem”为例
openssl rsa -inform DER -outform PEM -in privatekey.der -out privatekey.pem
2)提取证书命令,以“cert.cer”转换为“cert.pem”为例
openssl x509 -inform der -in cert.cer -out cert.pem
以上是几种比较流行的证书格式转换为PEM格式的方法,通过OpenSSL工具进行转换。