【问题标题】:How to convert an SSL certificate in linux如何在 Linux 中转换 SSL 证书
【发布时间】:2013-05-11 02:38:11
【问题描述】:

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

如何转换?

【问题讨论】:

    标签: linux ssl openssl certificate


    【解决方案1】:

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

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

    将 DER 文件 (.crt .cer .der) 转换为 PEM

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

    将 PEM 文件转换为 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

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

    将 PEM 证书文件和私钥转换为 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

    【讨论】:

      【解决方案2】:

      将 .crt 转换为 .p12

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

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

      【讨论】:

      • 感谢您扩展列表!
      猜你喜欢
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      相关资源
      最近更新 更多