CloudFront 上的子域不起作用(不接受证书)


  • 在证书管理器中,我有一个有效的证书,其中包括 *.example.com 域。
  • 在 CloudFront 中,我有一个启用了 HTTP 到 HTTPS 重定向且字段为空的分配。
  • 当我编辑分配并在 CNAME 字段中输入 staging.example.com 并选择证书时,出现以下错误:
com.amazonaws.services.cloudfront.model.InvalidViewerCertificateException: The certificate that is attached to your distribution doesn't cover the alternate domain name (CNAME) that you're trying to add. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidViewerCertificate; Request ID: 8406d8d5-65c3-11e9-afc0-65457a0a2bea)

我错过了什么吗?顶级域的另一个发行版使用相同的证书工作正常。

确保您只尝试让*.匹配单个子域。请参阅子域上的通配符 SSL

也就是说,*.example.com会匹配sub1.example.comsub2.example.com,但它不会匹配sub2.sub1.example.com。最后,您不能请求*.*.example.com证书。为了匹配最后一种情况,您必须请求*.sub1.example.com

通了。

证书是在错误的区域生成的。将在 CloudFront 分配上使用的证书必须在 us-east-1(弗吉尼亚州(上生成。

就我而言,我在us-east-1(北弗吉尼亚州(创建了一个SSL,但我仍然面临这个问题,当我在ACM中检查SSL时,它仅适用于子域,我忘记在请求SSL时添加根域。

因此,无论何时要使用 ACM,请确保 SSL 证书适用于域和子域(如果需要(。

如果使用无服务器,请尝试将certificateArn添加为serverless.yml文件中的组件输入

your-app:
  component: "@sls-next/serverless-component@latest"
  inputs:
    domain: ["app", "domain.com"] # [ sub-domain, domain ]
    certificateArn: "arn:aws:acm:us-east-1:<id>"

参考 : https://github.com/serverless-nextjs/serverless-next.js/issues/821

最新更新