跳至內容

如何對在為 CloudFront 發佈項目使用自訂 SSL 憑證時,發生的問題進行疑難排解?

2 分的閱讀內容
0

我想為 Amazon CloudFront 發佈項目的自訂 SSL 憑證進行疑難排解。

解決方法

**注意:**如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤訊息,請參閱對 AWS CLI 錯誤進行疑難排解。此外,請確定您使用的是最新的 AWS CLI 版本

請為您向 ACM 申請或匯入的憑證使用支援的 AWS 區域

若要將 AWS Certificate Manager (ACM) 憑證指派給 CloudFront 發佈項目,您必須在支援的 AWS 區域申請匯入憑證。如果您未在支援的區域中申請或匯入憑證,那麼您會收到錯誤訊息。

請為匯入至 IAM 的憑證指定正確的 CloudFront 路徑

最佳實務是使用 ACM 匯入憑證。如果您將 SSL 憑證匯入至 AWS Identity and Access Management (IAM),請提供正確的路徑,讓 CloudFront 能使用該憑證。

若要使用指定的 CloudFront 路徑匯入憑證,請執行以下 upload-server-certificate AWS CLI 命令:

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/

**注意:**請將 CertificateName 替換為您的憑證名稱,將 public_key_certificate_file 替換為您的公開金鑰檔案路徑,將 privatekey.pem 替換為您的私有金鑰檔案路徑,將 certificate_chain_file 替換為您的鏈結檔案路徑,並將 DistributionName 替換為您的 CloudFront 發佈項目。

如果您在匯入憑證時未指定 CloudFront 路徑,請執行以下 update-server-certificate AWS CLI 命令,使用路徑更新您的憑證:

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

**注意:**請將 CertificateName 替換為您的憑證名稱,並將 DistributionName 替換為您的 CloudFront 發佈項目名稱。

當您將憑證新增至 CloudFront 後,發佈項目的狀態會從已部署變更為I進行中。當變更部署到所有 CloudFront 邊緣節點後,發佈項目的狀態會變更回已部署

確認您具有所需的權限

如果您從 ACM 或 IAM 指派憑證,則用於指派憑證的 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 官方已更新 2 個月前