无法将 AWS cloudfront 与来自 IAM 的自定义 SSL 证书一起使用

Can't use AWS cloudfront with custom SSL cert from IAM

我有一个 CloudFront 分配,我想使用自定义证书通过 SSL 进行设置。

我们想使用已经上传到 IAM 的 SSL 证书(我们目前正在为一些 ELB 使用),但它甚至不让我们 select 选择(丢弃-down 证书应该是空的)。

有什么想法吗?根据官方文档,这应该是一个有效的选项

PS:我们不想使用 aws 证书管理器提供的证书

为 ELB 上传的自定义证书不能用于 CloudFront。

因此您需要再次上传 SSL 证书(可以是同一个证书),但略有不同。

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/

来源:https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-custom-certificate/

注意 --path 参数开头的 /cloudfront/

因此,最终,您将存储两份证书,一份供ELB 使用,一份供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/path/

--path Parameter – When you upload the certificate to IAM, the value of the -path parameter (certificate path) must start with /cloudfront/, for example, /cloudfront/production/ or /cloudfront/test/. The path also must end with a /.

详情在这里 http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html

根据我的经验,如果您将 IAM 证书上传到 /cloudfront 目录,您就可以在 ELB 上使用它。但是,您不能在不在 /cloudfront 目录中的 CloudFront 上使用 IAM 证书。