我想对用于 Amazon CloudFront 分配的自定义 SSL 证书进行故障排除。
解决方法
**注意:**如果您在运行 AWS 命令行界面 (AWS CLI) 命令时收到错误,请参阅 AWS CLI 错误故障排除。此外,请确保您使用的是最新版本的 AWS CLI。
为您从 ACM 请求或导入的证书使用受支持的区域
要将 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 分配添加证书后,分配的状态将从 Deployed(已部署)更改为 In Progress(正在进行)。将更改部署到所有 CloudFront 边缘站点时,分配的状态将变回 Deployed(已部署)。
确认您拥有所需的权限
如果您要分配来自 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 分配的 "InvalidViewerCertificate" 域名错误进行故障排除?
将 SSL/TLS 证书与 CloudFront 配合使用的要求
证书密钥的大小