更新时间:2022-06-07 05:45:20
在Linux中使用 OpenSSL 可以在cer / pem / crt / der / pfx / p12之间转换证书>工具。
Converting certificates between cer/pem/crt/der/pfx/p12 can be done in Linux with the use of OpenSSL tool via the terminal.
这些命令允许您将证书和密钥转换为不同的格式,使其与特定类型的服务器或软件兼容。
These commands allow you to convert certificates and keys to different formats to make them compatible with specific types of servers or software.
将DER文件(.crt .cer .der)转换为PEM
openssl x509 -inform der -in certificate.cer -out certificate.pem
openssl x509 -inform der -in certificate.cer -out certificate.pem
将PEM文件转换为DER
openssl x509 -outform der-in certificate.pem -out certificate.der
openssl x509 -outform der -in certificate.pem -out certificate.der
将包含私钥和证书的PKCS#12文件(.pfx .p12)转换为PEM
openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
您可以添加-nocerts仅输出私钥或add -nokeys仅输出证书。
You can add -nocerts to only output the private key or add -nokeys to only output the certificates.
将PEM证书文件和私钥转换为PKCS #12(.pfx .p12)
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
有关详细信息,请参阅:
For more information see:
http://www.sslshopper.com/article-most- common-openssl-commands.html
https://support.ssl.com/index.php?/Knowledgebase/Article/View/19