如何對將自訂 SSL 憑證用於 CloudFront 分佈的相關問題進行疑難排解?

2 分的閱讀內容
0

我想在我的 Amazon CloudFront 分佈的 AWS Certificate Manager (ACM) 或 AWS Identity and Access Management (IAM) 上進行自訂 SSL 憑證疑難排解。

簡短說明

以下是用於 CloudFront 分佈的自訂 SSL 憑證最常見的問題:

  • 設定分佈時,您無法選擇自訂 SSL 憑證。
  • 即使您可能可以使用與負載平衡器相同的憑證,也無法選擇 SSL 憑證。

解決方法

**注意:**如果您在執行 AWS Command Line Interface (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 分佈後,分佈的狀態會從已部署變更為進行中。當變更部署到所有 CloudFront 邊緣節點時,發行的狀態會變更回已部署。一般部署時間為 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 分佈「InvalidViewerCertificte」網域名稱錯誤?

將 SSL/TLS 憑證與 CloudFront 搭配使用的要求

AWS 官方
AWS 官方已更新 2 個月前