Skip to Content
Asterrr's Handbook
5 · Data protection

TLS on load balancers and CloudFront

SSL offload, re-encryption and passthrough on ELB, plus CloudFront viewer and origin protocol policies, custom certificates and field-level encryption.

Exam tasks: 5.1.1 (require encryption: load balancer security policies, TLS), 5.1.2 (secure private access)

The decision: on every hop between a client and your data, where is TLS terminated, who holds the private key, which protocol versions are allowed, and how do you prove nothing travels in cleartext?

TLS can terminate at the edge, at the load balancer, or on the instance. Choose by whether a middlebox may see plaintext.

viewer protocol policyorigin protocol policyre-encryptViewerCloudFrontALB, HTTPSlistenerTarget, HTTPS
Viewer to CloudFront, then to the origin, are separate TLS hops governed by separate settings. Field-level encryption protects chosen fields all the way to the application.
10
Fields that CloudFront field-level encryption can protect per request.

Which one to use

yesnoyesnoyesnoClient connects over TLSMust the load balancer seeHTTP: paths, headers, WAF,cookies?ALB HTTPSlistenerTraffic behind the ALBmust be encrypted too?Terminate HTTP to targetsRe-encrypt HTTPS targetgroupOnly the target may holdthe private key?Passthrough NLB TCPlistener, TLS on theinstanceNLB TLS listeneroptionally TLSto targets
Decision tree for where tls ends
PatternListenerCertificate lives onLoad balancer sees plaintextUse when
TerminateALB HTTPS or NLB TLS, HTTP/TCP to targetsLoad balancer (ACM)YesInternal hop is trusted, and you want offload
Re-encryptALB HTTPS to HTTPS targets, NLB TLS to TLS targetsLB and targetsYes, brieflyCompliance needs encryption on every hop, and you still want WAF or routing
PassthroughNLB TCP 443 to targetsTargets onlyNoKey must never leave your servers, or the target does its own mTLS
  • ALB handles HTTP and HTTPS. For other TLS protocols or for passthrough, use an NLB, which also supports TLS listeners that terminate.
  • An ALB doesn't validate the certificate on HTTPS targets, so self-signed or Private CA certificates on the targets are fine.
  • With passthrough, the load balancer can't add X-Forwarded-For or run AWS WAF, and ACM certificates can't be installed on the instances (unless you use an exportable ACM certificate or AWS Private CA).

Exam signal

"Load balancer must not see plaintext" means TCP/TLS passthrough on an NLB with the certificate on the instances. "Protect a single form field from every tier except the order service" means CloudFront field-level encryption.

Load balancer security policies

A security policy fixes the TLS versions and cipher suites the load balancer negotiates with clients.

Policy familyAllowsPick it for
ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09TLS 1.3 and 1.2, forward-secret ciphers, hybrid post-quantum key exchangeConsole default and the AWS recommendation
ELBSecurityPolicy-TLS13-1-2-2021-06TLS 1.3 and 1.2Broad compatibility without legacy protocols
ELBSecurityPolicy-TLS13-1-3-2021-06 (and -PQ- variants)TLS 1.3 only"Only TLS 1.3" requirements
...-FIPS-...FIPS-validated cryptographic modulesFedRAMP and FIPS 140 requirements
...-RFC9151-...CNSA 1.0 suitesUS national security workloads
ELBSecurityPolicy-2016-08Down to TLS 1.0Default for CLI, CloudFormation and CDK, so always set a policy explicitly
  • Forward secrecy (FS/PFS): every TLS 1.3 policy provides it, and so do TLS 1.2 policies limited to ECDHE ciphers. A stolen private key then can't decrypt previously recorded sessions.
  • ALB doesn't support custom policies; pick a predefined one. The policy for the ALB-to-target leg is derived from the listener policy, not chosen separately.
  • Restrict which policies teams may choose with the elasticloadbalancing:SecurityPolicy condition key in an SCP or IAM policy.
  • Enable connection logs on the ALB to see the negotiated TLS version and cipher per connection before you tighten a policy.
  • An HTTPS listener needs at least one server certificate and a security policy.
  • Security Hub control ELB.17 checks that HTTPS and TLS listeners use a recommended policy.

The default you didn't choose

A listener created with CloudFormation or the CLI without SslPolicy gets ELBSecurityPolicy-2016-08, which still allows TLS 1.0 and 1.1. When a scan finds "TLS 1.0 enabled on the load balancer" in an IaC-built stack, the fix is to set a TLS 1.2+ policy on the listener, not to rotate the certificate.

SNI and multiple certificates

  • ALB and NLB TLS listeners accept multiple certificates, and choose one per connection by the SNI host name the client sends. One listener can serve shop.example.com and api.example.org.
  • CloudFront serves custom certificates with SNI by default. A dedicated-IP option exists only for very old clients that don't send SNI.
  • The default certificate is used only when the client sends no SNI name or nothing matches.
  • ACM certificates on a load balancer renew automatically. Imported certificates do not.

Mutual TLS

WhereHow it works
ALB, verify modeUpload a CA bundle as a trust store (from S3), optionally with CRLs. The ALB rejects clients without a valid certificate and passes certificate details to targets in headers
ALB, passthrough modeThe ALB forwards the client's certificate chain in the X-Amzn-Mtls-Clientcert header, and your application verifies it
API GatewayCustom domain with a truststore in S3. Disable the default execute-api endpoint so clients can't skip mTLS
NLB TCP passthroughThe target terminates TLS and verifies client certificates itself

Private CA is the usual issuer for client certificates on devices, partner systems and internal services.

CloudFront

SettingOptionsSecure choice
Viewer protocol policy (per behaviour)HTTP and HTTPS, Redirect HTTP to HTTPS, HTTPS onlyRedirect or HTTPS only
Viewer security policyMinimum TLS version for viewersTLSv1.2_2021 or newer
Origin protocol policy (custom origins)HTTP only, HTTPS only, Match viewerHTTPS only
Origin SSL protocolsTLS versions to the originTLS 1.2
Custom domain certificateCertificate must cover the alternate domain name. Request it in ACM in us-east-1 or import itValid, matching name
Geo restrictionAllow list or block list of countriesNot a TLS control
  • The origin's certificate must be valid and match the origin domain name (or the Host header you forward). CloudFront won't connect to an origin with a self-signed certificate.
  • An S3 website endpoint only speaks HTTP. For HTTPS end to end, use the S3 REST endpoint with origin access control (OAC), which also works with SSE-KMS buckets.
  • Field-level encryption encrypts chosen POST form fields (up to 10) at the edge with an RSA 2048 public key you upload, using RSA-OAEP SHA-256. Only the component holding the private key, deep in your stack, can read them, so intermediate services and logs only see ciphertext.

Exam trap

Choosing "match viewer" does not secure the origin leg when viewers use HTTP. And an ALB cannot do passthrough of non-HTTP protocols.

Forcing TLS on AWS APIs and data stores

{
  "Sid": "DenyWithoutTls",
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": ["arn:aws:s3:::orders-archive-7731", "arn:aws:s3:::orders-archive-7731/*"],
  "Condition": { "Bool": { "aws:SecureTransport": "false" } }
}
  • Put the same deny on SQS queue policies, SNS topic policies and EFS file system policies.
  • Use s3:TlsVersion (numeric condition) to require a minimum version, for example a deny when s3:TlsVersion is NumericLessThan 1.3 for a TLS 1.3-only bucket.
  • AWS service API endpoints already require TLS 1.2 or later.
  • Hybrid links: Site-to-Site VPN (IPsec) or MACsec on dedicated Direct Connect connections. See VPN options and Direct Connect encryption.
us-east-1
ACM Region for CloudFront certificates.
198 days
Validity of new ACM public certificates.
45 days
ACM starts managed renewal this long before expiry.
7 days
Maximum validity in Private CA short-lived certificate mode.
10
Fields that CloudFront field-level encryption can protect per request.

Scenarios

Scenario
A payment processor's PCI assessor requires that cardholder data is encrypted on every network hop, including between the load balancer and the application instances. The application also needs AWS WAF rules and path-based routing. What should the security engineer configure?
Scenario
After a CloudFormation deployment, a vulnerability scan reports that a public ALB still accepts TLS 1.0 connections. The team must allow only TLS 1.2 and TLS 1.3 and keep forward secrecy, with the least effort. What should the security engineer do?

Further reading

On this page