Lesson 2 of 9 · 26m
TLS Termination and Certificate Operations
Configure modern TLS deliberately, automate certificate renewal, and avoid the certificate-chain and protocol mistakes that appear only for real clients.
TLS is one of those systems that looks finished right up until a customer calls because Android cannot connect but your laptop can. Termination is not just a certificate path. It is chain construction, protocol negotiation, session resumption, renewal timing, and the operational discipline to reload without breaking in-flight connections.
Terminate where policy is enforceable
Terminating TLS at Nginx or Apache centralizes cipher policy and certificate lifecycle. Passing TLS through to applications can be correct in zero-trust networks, but then every service owns its own renewal and protocol correctness. The common production compromise is TLS at the edge plus a controlled internal trust domain, sometimes with mTLS. Write down which model you operate; do not discover it during an incident.
Modern Nginx baseline
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;TLS 1.3 cipher suites are controlled by the client and library, not by the old cipher-string model. Session tickets disabled is a forward-secrecy tradeoff across multi-server deployments; enabling them without shared key rotation can weaken ticket confidentiality after compromise. This is why copying cipher lists from blog posts is not TLS administration.
Apache equivalent, with fewer surprises
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLHonorCipherOrder off
SSLSessionCache shmcb:/run/apache2/sslcache(512000)
SSLUseStapling onCheck the exact OpenSSL or BoringSSL build. Directive support and defaults vary by distribution. apache2ctl -M and openssl version -a are not trivia; they tell you which documentation applies.
Certificates fail in boring ways
A fullchain file should be leaf first, intermediates after it, root usually omitted:
-----BEGIN CERTIFICATE----- leaf: app.sudosecurity.org
-----BEGIN CERTIFICATE----- intermediate: R3/E1/etc.Verify what clients receive:
openssl s_client -connect app.sudosecurity.org:443 -servername app.sudosecurity.org -showcerts </dev/null
curl -Iv https://app.sudosecurity.org/If a browser works but curl or an API client fails, suspect missing intermediates, wrong SNI certificate, or stale certificate after a reload failure.
Automate renewal, verify deployment
Renewal is only half the job. Deployment is the other half:
certbot renew --deploy-hook 'nginx -t && systemctl reload nginx'The hook validates configuration before reload. Certbot writing new files does not mean Nginx or Apache has loaded them. Monitor certificate expiry externally; internal automation failure is exactly the condition you will not notice from the host itself.
Field notes
ssl_certificateneeds the full chain for broad client compatibility, even when one modern browser can fetch missing intermediates through AIA.- Test a second hostname with
openssl s_client -servername; default vhosts often mask SNI mistakes. - Do not redirect every HTTP request blindly; APIs and health checks may need explicit behavior during client migrations.
- After emergency certificate replacement, confirm the private key and certificate modulus match before blaming the CA.
Was this lesson helpful?