【问题标题】:Issue with verifying an App Service certificate in Azure在 Azure 中验证应用服务证书时出现问题
【发布时间】:2019-01-26 05:04:49
【问题描述】:

我的最终目标是在 Python 脚本中自动执行此过程,因此我首先要熟悉 Azure 门户中所需的工作流。

第 1 步是创建应用服务证书。在代码中,我的调用是: https://management.azure.com/subscriptions/aaaa-bbbb-cccc-dddd/resourceGroups/my-rg/providers/Microsoft.CertificateRegistration/certificateOrders/my-cert-order?api-version=2015-08-01

有效载荷为:

{
    "location": "global",
    "properties": {
        "productType": "StandardDomainValidatedSsl",
        "autoRenew": true,
        "distinguishedName":"CN=mydomain.com"
    }
}

第 2 步是将其与特定的密钥库相关联。同样,在代码中调用是: https://management.azure.com/subscriptions/aaaa-bbbb-cccc-dddd/resourceGroups/my-rg/providers/Microsoft.CertificateRegistration/certificateOrders/my-cert-order/certificates/my-cert?api-version=2015-08-01

有效载荷为

{
  "location":"global",
  "properties": {
    "keyVaultId":"/subscriptions/aaaa-bbbb-cccc-dddd/resourceGroups/my-rg/providers/Microsoft.KeyVault/vaults/my-keyvault",
    "keyVaultSecretName":"my-secret-name"
  }
}

第 3 步是验证与刚刚创建的证书关联的域。门户中的说明说使用提供的域验证令牌在我的域的根目录中创建一个 TXT 条目。我已经这样做了,但 Azure 不喜欢某些东西,因为它从不报告证书已被验证,即使在几个小时后也是如此。我尝试手动查找我创建的 TXT 记录,它现在肯定可用,所以我认为这不是 Azure 所抱怨的。

我知道门户使用的 REST 调用是验证域所有权,如此处所述:

https://docs.microsoft.com/en-us/rest/api/appservice/appservicecertificateorders/verifydomainownership

我尝试在代码中显式进行此调用,我可以看到它返回了 400 错误以及以下 JSON blob:

{
  "Code": "CertificateResellerWebService_NOT_FOUND_TOKEN",
  "Message": "All remaining domain control tokens were not found",
  "Target": null,
  "Details": [
    {
      "Message": "All remaining domain control tokens were not found"
    },
    {
      "Code": "CertificateResellerWebService_NOT_FOUND_TOKEN"
    },
    {
      "ErrorEntity": null
    }
  ],
  "Innererror": null
}

它在这里抱怨的域控制令牌是否与域验证令牌相同?无论如何,调用总是失败并出现同样的错误。我不清楚是什么导致了这个问题。任何建议将不胜感激。

更新:这是我用于该过程的主要算法:

token = get_auth_token()
# First, put in a certificate request
cert_order = create_cert_order(token, CERT_NAME)
while cert_order.status_code == 201:
    cert_order = get_cert_order(token, CERT_NAME)
cert_order = cert_order.json()
# Then assign it to a specific key vault
cert = update_cert(token, CERT_NAME, KEY_VAULT_ID, KEY_VAULT_SECRET_NAME)
while cert.status_code == 201:
    cert = get_cert(token, CERT_NAME)
# Next, create a TXT entry in the root domain matching the
# domain verification token and wait for that record to be
# discoverable by nslookup.
domain_verification_token = cert_order["properties"]["domainVerificationToken"]
create_txt_record(domain_verification_token)
waitfor_txt_record(domain_verification_token)
# Finally, ask to have to domain ownersip verified.
response = verify_domain_ownership(token, CERT_NAME)
if response.status_code != 204:
    print("Domain ownership verification failed")

这里引用的函数 create_cert_order、update_cert 和 verify_domain_ownership 代表我上面提到的 REST 调用。我很确定这个工作流程是正确的,但我不知道最终调用失败的原因。

【问题讨论】:

  • 为了它的价值,我已经发布了我在这个过程中遵循的主要工作流程。如果有人对完整代码感兴趣,我可以提供。

标签: azure ssl-certificate


【解决方案1】:

是的,应该是一样的。我可以在我这边重现这段代码CertificateResellerWebService_NOT_FOUND_TOKEN,这意味着域验证正在等待,仍然没有通过。

如果您选择手动验证。您可以访问您的 DNS 提供商,然后将名称为 @ 的 TXT 记录 并将 域验证码 添加到您的 根域。请注意,如果您为子域添加域验证,则应将相同的 TXT 记录添加到该根域而不是子域。请严格按照 Azure 门户上的这些步骤操作。

然后等待几分钟进行 DNS 传播。如果您仍有任何问题,请随时告诉我。

【讨论】:

  • 这正是我所做的,正如我上面提到的,按照说明创建 TXT 记录。然后我等了又等,但是当我运行验证域所有权时,我总是遇到同样的错误。使用 mxtoolbox.com/TXTLookup.aspx 手动查找 TXT 记录可验证 TXT 记录是可发现的,但由于某种原因,verify-domain-ownership 调用失败。
  • 你看到this:A certificate order has only 15 days to complete the domain verification operation. After 15 days, the certificate authority denies the certificate, and you are not charged for the certificate. In this situation, delete this certificate and try again.
  • 我看到的唯一错误是有关域控制令牌的消息。我还发现请求证书的过程会生成一封电子邮件至 webmaster@mydomain.com。此消息中有一个链接,可将您带到一个页面,在该页面中可以单击按钮来批准证书。如果我这样做,那么证书会在门户中显示为已获得批准,实际上在这种情况下我什至不必创建 TXT 记录。这对我来说不是一个解决方案,因为我想自动化请求/批准过程。
  • 我更新了我的原始帖子以包含我为执行步骤 1 和 2 所做的 REST 调用。这些工作没有问题。
  • 从您的原始帖子,第3步,听起来您使用手动验证。根据我的理解,如果您选择三个验证之一就可以了。现在你选择第二种方法:邮件验证,这行得通。实际上,我回答你错误代码没有通过验证。有时,你说你创建了一个 TXT,有时你没有。我觉得它很混乱。如果您真的正确地进行了手动验证,我相信它会起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多