跳至內容

為什麼我無法為 CloudFront 發佈項目選擇自訂 SSL/TLS 憑證?

2 分的閱讀內容
0

我想在設定 Amazon CloudFront 發佈項目時使用自訂 SSL/TLS 憑證,但我沒看到可選擇的選項。

簡短描述

在以下情況下,您可能看不到 CloudFront 發佈項目的自訂 SSL/TLS 憑證選項:

  • 您的憑證儲存在不同的 AWS 區域中。
  • AWS Certificate Manager (ACM) 憑證驗證失敗。
  • 憑證已過期。
  • 您沒有檢視或選取憑證所需的 AWS Identity and Access Management (IAM) 權限。

解決方法

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

檢查您的憑證組態

根據您的 CloudFront 發佈項目組態採取以下疑難排解動作。

ACM 憑證

如果您使用從 ACM 請求或匯入到 ACM 的憑證,請確認您的憑證符合以下要求:

如需詳細資訊,請參閱為什麼我找不到為負載平衡器或 CloudFront 發佈項目匯入的 ACM 憑證?

憑證已匯入 IAM

如果您已將 SSL/TLS 憑證匯入 IAM,請確認您使用的是正確的 CloudFront 路徑。執行以下 upload-server-certificate AWS CLI 命令,使用特定的 CloudFront 路徑上傳您的憑證:

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

**注意:**將 CertificateName 替換為您的憑證名稱,將 file://public_key_certificate_file 替換為您的公有金鑰,並將 file://privatekey.pem 替換為您的私有金鑰。另外,將 file://certificate_chain_file 替換為您的憑證鏈,並將 DistributionName 替換為您的 CloudFront 發佈項目名稱。

如果您未使用 CloudFront 路徑上傳憑證,請執行下列 update-server-certificate 命令以使用該路徑更新憑證:

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

注意:CertificateName 替換為您的憑證名稱,並將 DistributionName 替換為您的 CloudFront 發佈項目名稱。將憑證新增至 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"
        }
    ]
}

其他疑難排解

如果您將 SSL/TLS 憑證匯入 IAM,請確認憑證鏈的順序正確,且憑證未過期。如需詳細資訊,請參閱如何上傳 SSL 憑證並將其匯入 IAM?

若要在 CloudFront 發佈項目中使用多個網域名稱,需請求或產生包含所有必要網域的單一 SSL/TLS 憑證。預設情況下,ACM 支援每個憑證最多 100 個網域

**注意:**您無法將多個 SSL/TLS 憑證與單一 CloudFront 發佈項目建立關聯

相關資訊

如何使用 ACM 對 CloudFront 發佈項目網域名稱錯誤進行疑難排解?"InvalidViewerCertificate"

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