如何对用于 CloudFront 分配的自定义 SSL 证书的问题进行故障排除?

2 分钟阅读
0

我想对用于 Amazon CloudFront 分配的 AWS Certificate Manager (ACM) 或 AWS Identity and Access Management (IAM) 上的自定义 SSL 证书进行故障排除。

简短描述

以下是用于 CloudFront 分配的自定义 SSL 证书最常见的问题:

  • 在设置分配时,您没有找到选择自定义 SSL 证书的选项。
  • 尽管您可以将相同的证书用于负载均衡器,但却无法选择 SSL 证书。

解决方法

**注意:**如果您在运行 AWS 命令行界面 (AWS CLI) 命令时收到错误,请参阅 AWS CLI 错误故障排除。此外,确保您使用的是最新版本的 AWS CLI

要对用于 CloudFront 分配的自定义 SSL 证书的问题进行故障排除,请检查以下内容:

如果您使用的是从 ACM 请求的证书或导入到 ACM 的证书,请确认您的证书符合要求

如果您使用的是导入到 IAM 的证书,请验证 CloudFront 路径

将 SSL 证书导入 IAM 时,请提供正确的路径,以便 CloudFront 可以使用该证书。运行以下 AWS CLI 命令,以使用指定的 CloudFront 路径上传您的证书:

**注意:**在运行此命令之前,请确保将所有值替换为您的证书和 CloudFront 分配的详细信息。

aws iam upload-server-certificate --server-certificate-name CertificateName--certificate-body file://public_key_certificate_file --private-key file://privatekey.pem
--certificate-chain file://certificate_chain_file --path /cloudfront/DistributionName/

如果您未使用 CloudFront 路径上传证书,请运行此命令以使用以下路径更新您的证书:

aws iam update-server-certificate --server-certificate-name CertificateName --new-path /cloudfront/DistributionName/

**注意:**向 CloudFront 分配添加证书后,分配的状态将从 Deployed(已部署)更改为 In Progress(正在进行)。将更改部署到所有 CloudFront 边缘站点时,分配的状态将变回 Deployed(已部署)。典型的部署时间为 5 分钟

在将证书从 ACM 或 IAM 分配给 CloudFront 分配时,确认您拥有所需的权限

您用于分配证书的 IAM 用户或角色必须具有以下权限:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "acm:ListCertificates",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "cloudfront:ListDistributions",
        "cloudfront:ListStreamingDistributions"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "cloudfront:List*",
        "cloudfront:Get*",
        "cloudfront:Update*"
      ],
      "Resource": "arn:aws:cloudfront::account-id:distribution/distribution-id"
    },
    {
      "Effect": "Allow",
      "Action": "iam:ListServerCertificates",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "iam:GetServerCertificate",
        "iam:UpdateServerCertificate"
      ],
      "Resource": "arn:aws:iam::account-id:server-certificate/certificate-name-with-path"
    }
  ]
}

相关信息

如何使用 ACM 解决 CloudFront 分配的“InvalidViewerCertificate”域名错误?

在 CloudFront 中使用 SSL/TLS 证书的要求