【问题标题】:How to extract private key from pfx file using openssl? [closed]如何使用openssl从pfx文件中提取私钥? [关闭]
【发布时间】:2013-04-30 03:44:44
【问题描述】:

我一直在寻找此私钥以在 Softlayer 的“添加证书”向导中添加 ssl 证书,并进一步将其与本地负载均衡器一起使用。

我用谷歌搜索并尝试了以下 openssl 命令:

openssl pkcs12 -in filename.pfx -nocerts -out key.pem

但我最终得到了无效的“RSA PRIVATE KEY”。请帮忙。

【问题讨论】:

    标签: openssl private-key pkcs#12


    【解决方案1】:

    您可以在这个问题中检查两件事,

    1. 确保在您使用的 OpenSLL 命令中添加 -nodes 属性,因此提取的 RSA 私钥将是未加密的。例如,

      pkcs12 -in certificate-name.pfx -nocerts -nodes -out private-key.pem
      
    2. 你可以从 Private Key 中去掉 bag 和 key 属性行,试试看。

    在我的博客上查看对此问题的一个很好的解释:How To Extract Private Key From PFX Certificate File

    【讨论】:

    【解决方案2】:

    您的命令是正确的,并为您提供了 PKCS#8 格式的加密私钥。如果您需要未加密私钥,只需添加-nodes 选项:

    openssl pkcs12 -in filename.pfx -nocerts -nodes -out key.pem
    

    如果您需要旧 RSA 格式的私钥,您应该使用openssl pkcs8 命令转换给定的密钥:

    openssl pkcs8 -in key.pem -out rsakey.pem
    

    详见文档:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-26
      • 2013-12-10
      • 2017-12-18
      • 2018-06-07
      • 2010-10-08
      • 2018-02-22
      • 1970-01-01
      • 2013-04-22
      相关资源
      最近更新 更多