Networking
TLS and certificates
How HTTPS keeps data private and proves the server's identity, how the TLS 1.3 handshake works, and why expired certificates keep causing outages. Start here for TLS.
Every https:// address runs on TLS (Transport Layer Security). It encrypts the data, detects changes to it and proves that the server is who it claims to be. Most web traffic, most API calls and many database connections use it. You may rarely write TLS code, but you will configure it, terminate it and get paged when it breaks. An expired certificate is one of the most common causes of full outages, and "TLS handshake failed" is an error you will see often.
The big idea: two jobs
TLS does two things, in sequence.
- Agree on keys. The client and the server use the handshake to create a shared secret key. The key is made fresh for each connection, so an eavesdropper cannot learn it.
- Prove identity. The server presents a certificate, which is a signed statement that binds its public key to a hostname. The client checks the signature by following a chain back to a root it already trusts.
Both jobs depend on the same idea. A signature from a trusted issuer is hard to forge, and a fresh key is hard to steal. If either one fails, the connection should be refused.
Concepts in this section
Read them in this order.
| Step | Concept | What it answers |
|---|---|---|
| 1 | What TLS guarantees | What does TLS protect, and what does it leave visible? |
| 2 | The TLS 1.3 handshake | How do the ends agree on keys in one round trip? |
| 3 | Certificates and chains | How does the client know the server's name is real? |
| 4 | Certificate expiry and renewal | How do I stop renewals from taking the site down? |
| 5 | Terminating TLS and mTLS | Where does the encryption end, and how do services prove identity to each other? |
In practice
- Never disable certificate checks to make an error go away. Turning off verification removes the authentication. Fix the chain, or add the right CA.
- Automate renewal and monitor expiry separately. Certificate lifetimes are shrinking toward 47 days, so renewal by hand will not keep up.
- Know where TLS ends in your system, and what is plaintext after that point.
- Use TLS 1.2 as the minimum and prefer TLS 1.3. Turn off TLS 1.0 and 1.1, which browsers stopped supporting in 2020.
- Use mTLS with short-lived identities for traffic between services, instead of shared API keys.
- Test from the command line.
openssl s_client -connect host:443 -servername hostshows the chain the server actually sends. A browser can hide problems that other clients will hit.
Common mistakes
- Trusting a browser test alone. A missing intermediate certificate often works in Chrome and fails in scripts.
- Renewing on the last day. One failed attempt then becomes an outage.
- Assuming encryption is enough. Without the certificate check, a man in the middle can read everything.
- Forgetting internal certificates. Internal CAs and mTLS certificates expire as well.
Key takeaways
- TLS agrees on fresh keys with the handshake, and it proves identity with a signed certificate.
- TLS 1.3 needs one round trip for the handshake. Connection reuse makes the cost mostly one-time.
- A certificate is trusted through a chain of signatures from a root the client already has.
- Expiry is intentional, and it is the main safety net. Automate renewal and monitor expiry from outside.
- Use
openssl s_clientto check the chain, and use mTLS with short-lived identities between services.
Further learning
Practical Networking's video goes message by message through opening an HTTPS site, including certificates and key derivation. It pairs well with the handshake page.
Related
What TLS guarantees
The three things TLS does for every HTTPS connection (confidentiality, integrity and authentication), where it sits in the stack, and what it does not hide.
The TLS 1.3 handshake
How client and server agree on secret keys in one round trip, why the keys are thrown away afterwards, and what 0-RTT resumption costs in replay risk.
Certificates and chains of trust
What an X.509 certificate says, how a leaf certificate links to a trusted root through intermediates, why a missing intermediate breaks some clients, and how Let's Encrypt and Certificate Transparency fit in.
Certificate expiry and renewal
Why certificates expire on purpose, why expired ones take sites down, and the playbook for automated renewal, independent monitoring and a full inventory. Includes a check you can run in a minute.
Terminating TLS and mTLS
Where an encrypted connection ends and plaintext begins, the three common placements, and how mutual TLS with short-lived workload identities protects traffic between services.
Cryptography for engineers
The few building blocks you need for everyday security decisions, which question each one answers, and where teams go wrong. Start here for the map.
HTTP/1.1, HTTP/2 and HTTP/3
The protocol of the web. Separates HTTP's meaning (methods, status codes, caching) from its wire format, and shows how each version fixes the latency problem of the one before.