如何在Linux中转换SSL证书 [英] How to convert an SSL certificate in linux
问题描述
有一种方法如何在cer / pem / crt / der / pfx / p12在Linux中转换证书?我在.cer文件中有一个SSL证书,我需要它是.pem才能使用。
Is there a way how to convert certificates between cer/pem/crt/der/pfx/p12 in Linux? I have an SSL certificate in a .cer file and I need it to be .pem in order to use it.
如何转换?
推荐答案
在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
这篇关于如何在Linux中转换SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!