【问题标题】:How to solve AWS CloudFront SSL Certificate Doesn't Exist如何解决 AWS CloudFront SSL 证书不存在的问题
【发布时间】:2021-08-08 21:23:02
【问题描述】:

当我在 CloudFormation 中将 IamCertificateId 属性添加到我的 AWS::CloudFront::Distribution 时,出现以下错误:

资源处理程序返回消息:“提供的请求无效:指定的 SSL 证书不存在、不在 us-east-1 区域、无效或不包含有效的证书链。”

我确实通过运行aws iam list-server-certificates command 并确保IamCertificateId 属性的值与证书的the ASCA prefixed IAM ID 匹配来确保证书存在。

我忽略了us-east-1 区域消息,因为 IAM 是一项全球服务并且我没有使用 ACM 证书。另外,我在中国cn-north-1 地区开展业务,以防万一。

我很确定证书是“有效的”,因为我假设如果证书格式不正确,AWS 不会允许我使用 upload the certificate with aws iam upload-server-certificate

因此,错误消息并未将我指向解决方案。我可能会错过什么?

【问题讨论】:

    标签: amazon-web-services ssl amazon-cloudformation amazon-cloudfront amazon-iam


    【解决方案1】:

    您的证书可能有效,但可能对 CloudFront 无效。错误消息没有指出的是您可以在 the docs for uploading a certificate 中找到的内容:

    注意: 如果您要上传专门用于 Amazon CloudFront 分配的服务器证书,则必须使用 path 参数指定路径。路径必须以 /cloudfront 开头,并且必须包含一个斜杠(例如 /cloudfront/test/ )。

    因此,请确保在 aws iam upload-server-certificate 命令中添加 --path "/cloudfront/"

    【讨论】:

    • 我已经添加了路径"/cloudfront/",但是问题依旧存在。
    • Yann Stoneman,您是如何为云端分发生成私钥、证书主体和证书链的?我跟着this tutorial生成了三个文件。
    • @Brian -- 就我而言,我团队中的其他人给了我一个 PFX 编码的签名证书文件,然后我在 AWS 上按照这篇文章将它们转换为 AWS 可接受的格式:@987654323 @
    • 根据document,CloudFront 证书的长度不能超过 2048 位。我的证书是 4096 位,这就是我的问题的原因。
    【解决方案2】:

    我遇到了这个问题,这是因为我的构建系统在 Windows 上意外切换了斜线 /(但它在 Linux 上运行)。我的 CloudFormation 文件有:

            "CloudfrontDistribution": {
                "Type": "AWS::CloudFront::Distribution",
                "DependsOn": "CloudfrontS3LogsBucket",
                "Condition": "DRDeactivated",
                "Properties": {
                    "DistributionConfig": {
    <--- snip snip -->
                        "ViewerCertificate": {
                            "AcmCertificateArn": "arn:aws:acm:us-east-1:0123456789:certificate\\XXXX-XXXX-XXXX-XXXX",
                            "SslSupportMethod": "sni-only",
                            "MinimumProtocolVersion": "TLSv1.2_2019"
                        }
                    }
                }
            }
        },
    

    上面的 Cloud Formation 代码中的 AcmCertificateArn 错误。而不是

    "AcmCertificateArn": "arn:aws:acm:us-east-1:0123456789:certificate\\XXXX-XXXX-XXXX-XXXX",
    

    应该是:

    "AcmCertificateArn": "arn:aws:acm:us-east-1:0123456789:certificate/XXXX-XXXX-XXXX-XXXX",
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      • 2021-01-22
      • 1970-01-01
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多