gpt4 book ai didi

azure - 如何让 AzureRM 应用程序网关将 ACME .PEM 证书作为 AGW SSL 端到端配置中的 trust_root_certificates?

转载 作者:行者123 更新时间:2023-12-03 04:02:22 24 4
gpt4 key购买 nike

我正在尝试通过 ACME 提供程序使用 Terraform 和 Letsencrypt 在 Azure 应用程序网关 v2.0 中创建 azurerm backend_http_settings。

我可以成功创建证书并将 .pfx 导入前端 https 监听器,acme 和 azurerm 提供商提供处理 pkcs12 所需的一切。

不幸的是,后端需要一个 .cer 文件,大概是用 base64 编码的,而不是 DER,无论我如何尝试,我都无法让它工作。我的理解是,letsencrypt .pem 文件应该可以满足此要求,但是当我尝试使用 acme 提供程序的certificate_pem 作为trusted_root_certificate 时,我收到以下错误:

Error: Error Creating/Updating Application Gateway "agw-frontproxy" (Resource Group "rg-mir"): network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="ApplicationGatewayTrustedRootCertificateInvalidData" Message="Data for certificate .../providers/Microsoft.Network/applicationGateways/agw-frontproxy/trustedRootCertificates/vnet-mir-be-cert is invalid." Details=[]

terraform 计划工作正常,当 azurerm 提供商因证书数据无效而生气时,在 terraform 应用期间会发生上述错误。我已将证书写入磁盘,它们看起来正如我所期望的那样。这是包含相关代码的代码片段:

locals {
https_setting_name = "${azurerm_virtual_network.vnet-mir.name}-be-tls-htst"
https_frontend_cert_name = "${azurerm_virtual_network.vnet-mir.name}-fe-cert"
https_backend_cert_name = "${azurerm_virtual_network.vnet-mir.name}-be-cert"
}
provider "azurerm" {
version = "~>2.7"
features {
key_vault {
purge_soft_delete_on_destroy = true
}
}
}
provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
}
resource "acme_certificate" "certificate" {
account_key_pem = acme_registration.reg.account_key_pem
common_name = "cert-test.example.com"
subject_alternative_names = ["cert-test2.example.com", "cert-test3.example.com"]
certificate_p12_password = "<your password here>"
dns_challenge {
provider = "cloudflare"

config = {
CF_API_EMAIL = "<your email here>"
CF_DNS_API_TOKEN = "<your token here>"
CF_ZONE_API_TOKEN = "<your token here>"
}
}
}
resource "azurerm_application_gateway" "agw-frontproxy" {
name = "agw-frontproxy"
location = azurerm_resource_group.rg-mir.location
resource_group_name = azurerm_resource_group.rg-mir.name

sku {
name = "Standard_v2"
tier = "Standard_v2"
capacity = 2
}
trusted_root_certificate {
name = local.https_backend_cert_name
data = acme_certificate.certificate.certificate_pem
}
ssl_certificate {
name = local.https_frontend_cert_name
data = acme_certificate.certificate.certificate_p12
password = "<your password here>"
}
# Create HTTPS listener and backend
backend_http_settings {
name = local.https_setting_name
cookie_based_affinity = "Disabled"
port = 443
protocol = "Https"
request_timeout = 20
trusted_root_certificate_names = [local.https_backend_cert_name]
}

如何让 AzureRM 应用程序网关将 ACME .PEM 证书作为 AGW SSL 端到端配置中的 trust_root_certificates?

最佳答案

对我来说,唯一有效的方法是使用紧密耦合的 Windows 工具。如果您遵循以下文档,它将起作用。花了 2 天时间解决同样的问题:)

Microsoft Docs

关于azure - 如何让 AzureRM 应用程序网关将 ACME .PEM 证书作为 AGW SSL 端到端配置中的 trust_root_certificates?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61529875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com