首页 文章

如何在linux中转换SSL证书

提问于
浏览
20

有没有办法在Linux中如何在cer / pem / crt / der / pfx / p12之间转换证书?我在.cer文件中有一个SSL证书,我需要它.pem才能使用它 .

我怎么转换它?

3 回答

  • 50

    在cer / pem / crt / der / pfx / p12之间转换证书可以在Linux中通过终端使用 OpenSSL 工具完成 .

    这些命令允许您将证书和密钥转换为不同的格式,以使它们与特定类型的服务器或软件兼容 .

    Convert a DER file (.crt .cer .der) to PEM

    openssl x509 -inform der -in certificate.cer -out certificate.pem

    Convert a PEM file to DER

    openssl x509 -outform der -in certificate.pem -out certificate.der

    Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM

    openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes

    您可以添加-nocerts以仅输出私钥或添加-nokeys以仅输出证书 .

    Convert a PEM certificate file and a private key to PKCS#12 (.pfx .p12)

    openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

    有关更多信息,请参阅

    http://www.sslshopper.com/article-most-common-openssl-commands.html https://support.ssl.com/index.php?/Knowledgebase/Article/View/19

  • -1

    Convert .crt to .p12

    openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt

    其中server.key是服务器密钥 . server.crt是来自CA的证书文件或自我叹息

  • 1

    如何为您的离子应用程序简单生成.cer文件?

    我们可以通过 using google chrome browser 轻松导出https网址的.cer文件 . 只需单击挂锁图标并将密钥文件导出为基于base64的.cer文件

    参考

    http://uncaughterror.com/programming/ionic3/how-to-integrate-ssl-in-ionic-3-using-cordova-plugin/

    https://www.youtube.com/watch?v=6nLK9wJPNRE

    Doing the same using a linux machine

    openssl s_client -showcerts -connect <domain name>:443 -servername <domain name>:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > certificate.pem
    

    将.pem文件转换为.cer文件

    openssl x509 -inform PEM -in certificate.pem -outform DER -out certificate.cer
    

相关问题