【问题标题】:Trying to create a password-protected PFX file results in openssl error: "尝试创建受密码保护的 PFX 文件会导致 openssl 错误:“
【发布时间】:2017-11-19 07:08:05
【问题描述】:

背景

  • 我们有 MS Azure 云主机
  • 从第三方(不是 Microsoft)为我的域购买了通配符 SSL 证书
  • 创建了 CSR 文件 + 私钥文件
  • 已使用这些证书并已获得 SSL 颁发者颁发的 x509PKCS7 证书
  • Azure 需要 PFX 文件,因此一直在尝试遵循此处的 ssl.com 教程:https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/

问题

在我的本地机器上的终端中运行 openssl 命令(插入中断以提高可读性)

openssl pkcs12 -export -out certificate.pfx -password pass:somepassword
-inkey domain.key -in certificate.crt

我收到以下错误:

140735704675208:error:0906D06C:PEM routines:PEM_read_bio:no start line
:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22/libressl/crypto/pem/pem_lib.c:704:
Expecting: ANY PRIVATE KEY

但是我已经提供了钥匙?我很困惑。谈到 Azure,我是 SSL 初学者。我做错了什么?

注意,我包含了 -password 参数,因为 MS Azure 希望 PFX 文件受到密码保护。这不是可选的:它们必须受到保护。

编辑

使用 Openssl 重新生成 CSR 和密钥后,我收到一个新错误,即密钥文件无效。为了确保我没有遗漏一些明显的东西:

  • 我可以用 X509 做什么?
  • 我可以用 PKCS7 做什么?

【问题讨论】:

  • 我刚刚在我自己的 comodo 证书中输入了您的命令并且它有效。请检查 pem 文件(带有 openssl rsa -in domain.key -check 的密钥,crt 和密钥的模数应匹配 openssl x509 -noout -modulus -in certificate.crt | openssl md5 并且对于键 openssl rsa -noout -modulus -in domain.key | openssl md5)
  • 谢谢@J.M.Robles - 我遵循了这些步骤:openssl rsa -in domain.key -check 结果为unable to load Private Key 140735704675208:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22/libressl/crypto/pem/pem_lib.c:704:Expecting: ANY PRIVATE KEY
  • 嗯,您的 domain.key 文件有问题。请编辑它以检查它是否是一个好的 pem 文件,如果是,则密钥是否已加密(第一行)。我的没有加密(-----BEGIN PRIVATE KEY-----)。
  • @J.M.Robles - 我的 .key 文件以 -----BEGIN PRIVATE KEY----- / -----END PRIVATE KEY----- 开始/结束?
  • 加密密钥以 -----BEGIN ENCRYPTED PRIVATE KEY----- 开头。你的文件不是(我的也不是)。请测试行是否以 \r\n 结尾(在我的文件中,它们以 \n 结尾)并尝试使用 openssl 的其他实现(其他操作系统)。

标签: azure ssl openssl


【解决方案1】:

厌倦了使用 openssl 和终端,所以找到了一个 GUI 来做这件事。步骤:

这会生成一个受密码保护的 PFX,然后可以将其上传到 Azure。

【讨论】:

    猜你喜欢
    • 2010-09-22
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2013-07-22
    • 2010-11-18
    • 1970-01-01
    相关资源
    最近更新 更多