Description
On a standard CloudFront distribution, the default certificate covers the assigned cloudfront.net hostname. Adding a custom domain to that distribution requires a certificate that covers it. If you specify a custom certificate in ViewerCertificate, you must also set MinimumProtocolVersion and SslSupportMethod.
To restrict access to private content, use separate controls such as signed URLs or signed cookies.
Potential impact
- A standard distribution rejects an alternate domain name that its certificate does not cover.
- A TLS policy that does not meet service requirements can permit obsolete protocols.
Remediation
For a standard distribution, keep the default certificate when the distribution uses only its cloudfront.net hostname. For custom domains, list them in Aliases, omit the default certificate setting, and supply a certificate that covers those names. Use AcmCertificateArn for an ACM certificate in us-east-1 or IamCertificateId for a certificate stored in IAM. Set MinimumProtocolVersion and SslSupportMethod to suit the clients that connect.
On a multi-tenant distribution, register the domain on its tenant. The tenant can serve a DNS-verified domain over HTTP. For HTTPS, use a matching ACM certificate on the distribution or tenant.
Examples
Both excerpts use cdn.example.com as an alternate domain. Use the ARN of an ACM certificate in us-east-1 that covers your domain. The excerpts omit the origin and cache behavior.
Before
Resources:
MyDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Aliases:
- cdn.example.com
ViewerCertificate:
CloudFrontDefaultCertificate: true
This standard distribution cannot add cdn.example.com with its default certificate. When it uses that certificate, its security policy is fixed at TLSv1.
After
Resources:
MyDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Aliases:
- cdn.example.com
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:111122223333:certificate/11111111-1111-4111-8111-111111111111
MinimumProtocolVersion: TLSv1.2_2019
SslSupportMethod: sni-only
With TLSv1.2_2019 and sni-only, HTTPS clients must support TLS 1.2 or later and SNI. To allow only HTTPS requests, set the cache behavior’s ViewerProtocolPolicy to https-only.