Apply TLS Configuration
Configure TLS 1.2+ with modern cipher suites, valid certificates, and HSTS — eliminating downgrade attacks, weak encryption, and certificate validation failures.
Why This Is Best Practice
Adopted by: NIST SP 800-52 Rev 2 mandates TLS 1.2 minimum for US federal systems. PCI DSS v4.0 Requirement 4.2 requires TLS 1.2+ and explicitly prohibits SSL/TLS 1.0/1.1. Google Chrome marks all HTTP as "Not Secure" since 2018. Let's Encrypt has issued over 3 billion certificates, removing cost as a barrier. Mozilla's Server Side TLS guidelines are the de facto industry reference used by AWS, Cloudflare, and Fastly.
Impact: POODLE (SSLv3), BEAST (TLS 1.0), SWEET32 (3DES), LUCKY13, and DROWN are all cryptographic attacks against weak TLS versions and ciphers — each enabled by misconfigured servers. Qualys SSL Labs A+ rating requires TLS 1.2+, forward secrecy, and HSTS — servers scoring below B are vulnerable to known-exploitable attacks. Forward secrecy (ECDHE) ensures past sessions cannot be decrypted even if the private key is later compromised.
Why best: Custom cipher configuration over accepting server defaults — because OpenSSL and platform defaults often include legacy ciphers for backward compatibility. Mozilla's "Intermediate" profile balances security and broad client compatibility; "Modern" maximizes security for internal services.
Sources: OWASP TLS Cheat Sheet; Mozilla SSL Config Generator; NIST SP 800-52 Rev 2; Qualys SSL Labs research; CWE-326
Steps
Enforce TLS 1.2 minimum; prefer TLS 1.3:
Nginx:
ssl_protocols TLSv1.2 TLSv1.3;
Apache:
SSLProtocol -all +TLSv1.2 +TLSv1.3
Node.js:
const tls = require('tls');
// Node defaults to TLS 1.2+ since v12 — verify with:
console.log(tls.DEFAULT_MIN_VERSION); // should be TLSv1.2
Configure forward-secret cipher suites (Mozilla Intermediate profile):
Nginx:
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
All ciphers use ECDHE/DHE (forward secrecy) and AEAD (authenticated encryption). No RC4, 3DES, or CBC-mode ciphers.
Obtain and renew certificates automatically — use Let's Encrypt (free, 90-day, auto-renewable):
# Certbot (most common)
certbot --nginx -d example.com -d www.example.com
# Auto-renewal via cron (certbot installs this automatically)
For AWS: use ACM (AWS Certificate Manager) — free certificates, auto-renewed, no manual rotation.
For Kubernetes: use cert-manager with Let's Encrypt ClusterIssuer.
Enable HSTS with preload:
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
Submit to HSTS preload list at hstspreload.org after testing. See apply-security-headers for full context.
Enable OCSP stapling — server proves certificate validity without client round-trip:
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /path/to/chain.pem;
resolver 8.8.8.8 1.1.1.1 valid=300s;
Set DH parameters for DHE ciphers (2048-bit minimum):
openssl dhparam -out /etc/nginx/dhparam.pem 2048
ssl_dhparam /etc/nginx/dhparam.pem;
Test with Qualys SSL Labs — run ssllabs.com/ssltest/ against your domain. Target A+ grade. Address all flagged findings before production launch.
Validate certificate chain — ensure full chain (leaf + intermediates) is served. Missing intermediates cause failures on some clients:
openssl s_client -connect example.com:443 -showcerts < /dev/null
# Verify chain shows: leaf → intermediate → root
Rules
- Never use self-signed certificates in production — clients will either reject them or users will train themselves to click through warnings.
- Certificate pinning (HPKP) is deprecated — it caused widespread outages when misused; do not implement.
ssl_prefer_server_ciphers off is correct for TLS 1.3 (client chooses) — leave it off.
- Wildcard certificates (
*.example.com) cover one subdomain level only — they don't cover sub.sub.example.com.
Common Mistakes
- Using default OpenSSL ciphers — includes RC4, 3DES, and export ciphers on older OpenSSL versions.
- Not renewing certificates before expiry — automate renewal; calendar reminders are insufficient at scale.
- Serving HTTP and HTTPS on the same domain without a redirect — configure HTTP to redirect 301 to HTTPS permanently.
- Forgetting to include the intermediate certificate — chain failures are the #1 TLS deployment error.
1---2name: apply-tls-configuration3description: Use when configuring HTTPS on a web server, API gateway, or load balancer — covers cipher suites, TLS version enforcement, certificate management, and HSTS.4source: 'OWASP Transport Layer Security Cheat Sheet (owasp.org/www-project-cheat-sheets); Mozilla SSL Configuration Generator; NIST SP 800-52 Rev 2; CWE-326'5tags: [security, owasp, tls, https, ssl, certificates, devops, developer]6metadata:7 source: https://skillmd.com/skills/jeffreytse/apply-tls-configuration8---910# Apply TLS Configuration1112Configure TLS 1.2+ with modern cipher suites, valid certificates, and HSTS — eliminating downgrade attacks, weak encryption, and certificate validation failures.1314## Why This Is Best Practice1516**Adopted by:** NIST SP 800-52 Rev 2 mandates TLS 1.2 minimum for US federal systems. PCI DSS v4.0 Requirement 4.2 requires TLS 1.2+ and explicitly prohibits SSL/TLS 1.0/1.1. Google Chrome marks all HTTP as "Not Secure" since 2018. Let's Encrypt has issued over 3 billion certificates, removing cost as a barrier. Mozilla's Server Side TLS guidelines are the de facto industry reference used by AWS, Cloudflare, and Fastly.17**Impact:** POODLE (SSLv3), BEAST (TLS 1.0), SWEET32 (3DES), LUCKY13, and DROWN are all cryptographic attacks against weak TLS versions and ciphers — each enabled by misconfigured servers. Qualys SSL Labs A+ rating requires TLS 1.2+, forward secrecy, and HSTS — servers scoring below B are vulnerable to known-exploitable attacks. Forward secrecy (ECDHE) ensures past sessions cannot be decrypted even if the private key is later compromised.18**Why best:** Custom cipher configuration over accepting server defaults — because OpenSSL and platform defaults often include legacy ciphers for backward compatibility. Mozilla's "Intermediate" profile balances security and broad client compatibility; "Modern" maximizes security for internal services.1920Sources: OWASP TLS Cheat Sheet; Mozilla SSL Config Generator; NIST SP 800-52 Rev 2; Qualys SSL Labs research; CWE-3262122## Steps23241. **Enforce TLS 1.2 minimum; prefer TLS 1.3**:2526 **Nginx:**27 ```nginx28 ssl_protocols TLSv1.2 TLSv1.3;29 ```3031 **Apache:**32 ```apache33 SSLProtocol -all +TLSv1.2 +TLSv1.334 ```3536 **Node.js:**37 ```javascript38 const tls = require('tls');39 // Node defaults to TLS 1.2+ since v12 — verify with:40 console.log(tls.DEFAULT_MIN_VERSION); // should be TLSv1.241 ```42432. **Configure forward-secret cipher suites (Mozilla Intermediate profile)**:4445 **Nginx:**46 ```nginx47 ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;48 ssl_prefer_server_ciphers off;49 ```5051 All ciphers use ECDHE/DHE (forward secrecy) and AEAD (authenticated encryption). No RC4, 3DES, or CBC-mode ciphers.52533. **Obtain and renew certificates automatically** — use Let's Encrypt (free, 90-day, auto-renewable):5455 ```bash56 # Certbot (most common)57 certbot --nginx -d example.com -d www.example.com58 # Auto-renewal via cron (certbot installs this automatically)59 ```6061 For AWS: use ACM (AWS Certificate Manager) — free certificates, auto-renewed, no manual rotation.62 For Kubernetes: use cert-manager with Let's Encrypt ClusterIssuer.63644. **Enable HSTS with preload**:6566 ```nginx67 add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;68 ```6970 Submit to HSTS preload list at `hstspreload.org` after testing. See `apply-security-headers` for full context.71725. **Enable OCSP stapling** — server proves certificate validity without client round-trip:7374 ```nginx75 ssl_stapling on;76 ssl_stapling_verify on;77 ssl_trusted_certificate /path/to/chain.pem;78 resolver 8.8.8.8 1.1.1.1 valid=300s;79 ```80816. **Set DH parameters for DHE ciphers** (2048-bit minimum):8283 ```bash84 openssl dhparam -out /etc/nginx/dhparam.pem 204885 ```8687 ```nginx88 ssl_dhparam /etc/nginx/dhparam.pem;89 ```90917. **Test with Qualys SSL Labs** — run `ssllabs.com/ssltest/` against your domain. Target A+ grade. Address all flagged findings before production launch.92938. **Validate certificate chain** — ensure full chain (leaf + intermediates) is served. Missing intermediates cause failures on some clients:9495 ```bash96 openssl s_client -connect example.com:443 -showcerts < /dev/null97 # Verify chain shows: leaf → intermediate → root98 ```99100## Rules101102- Never use self-signed certificates in production — clients will either reject them or users will train themselves to click through warnings.103- Certificate pinning (HPKP) is deprecated — it caused widespread outages when misused; do not implement.104- `ssl_prefer_server_ciphers off` is correct for TLS 1.3 (client chooses) — leave it off.105- Wildcard certificates (`*.example.com`) cover one subdomain level only — they don't cover `sub.sub.example.com`.106107## Common Mistakes108109- **Using default OpenSSL ciphers** — includes RC4, 3DES, and export ciphers on older OpenSSL versions.110- **Not renewing certificates before expiry** — automate renewal; calendar reminders are insufficient at scale.111- **Serving HTTP and HTTPS on the same domain without a redirect** — configure HTTP to redirect 301 to HTTPS permanently.112- **Forgetting to include the intermediate certificate** — chain failures are the #1 TLS deployment error.