How HTTPS and TLS Really Work: A Practical Guide
You type https:// and see a padlock, but what actually happens between your browser and the server? Many developers treat HTTPS as a black box—until something breaks in production. This guide walks through the TLS handshake, certificate validation, and the encryption that protects your data, with practical steps to debug common issues.
Why HTTPS Exists: The Three Guarantees
HTTPS is HTTP layered on top of TLS (Transport Layer Security). It provides three core properties:
- Confidentiality – Eavesdroppers can't read the data.
- Integrity – Data can't be modified in transit without detection.
- Authentication – You're talking to the real server, not an impostor.
Without TLS, anyone on the network path (Wi‑Fi operator, ISP, malicious router) can read or alter traffic. TLS solves this with a mix of asymmetric and symmetric cryptography.
The TLS Handshake in Plain English
Before any HTTP request is sent, the client and server perform a handshake to agree on keys and verify identities. Modern TLS 1.3 simplifies this to one round trip, but the concepts are the same.
- Client Hello – The browser sends supported TLS versions, cipher suites, and a random value.
- Server Hello – The server picks a cipher suite, sends its own random value, and presents its certificate chain.
- Certificate Validation – The browser checks the certificate's signature, expiration, and domain name against trusted root CAs.
- Key Exchange – Using ephemeral Diffie‑Hellman (or similar), both sides derive a shared secret without transmitting it.
- Finished – Both sides send a MAC over the handshake transcript to confirm integrity.
After the handshake, all HTTP data is encrypted with symmetric keys (e.g., AES‑GCM or ChaCha20‑Poly1305), which are much faster than asymmetric operations.
Symmetric vs Asymmetric: Why Both?
Asymmetric cryptography (RSA, ECDSA) is used only during the handshake for authentication and key exchange. It's computationally expensive. Symmetric encryption handles the bulk data because it's efficient. TLS combines them: asymmetric to establish trust, symmetric to protect the session.
| Operation | Type | Purpose |
|---|---|---|
| Certificate signing | Asymmetric | Prove server identity |
| Key exchange | Asymmetric / ECDHE | Derive shared secret |
| Bulk data encryption | Symmetric | Fast confidentiality & integrity |
Certificate Validation: The Chain of Trust
Browsers trust a set of root CAs preinstalled in the OS or browser. A server certificate is signed by an intermediate CA, which is signed by a root CA. The browser builds a chain and verifies each signature. If any link is missing or invalid, you get a warning.
Common validation failures:
- Expired certificate – Check the
Not Afterdate. - Hostname mismatch – The certificate's Subject Alternative Name (SAN) must include the domain.
- Incomplete chain – The server must send intermediate certificates; browsers often don't fetch them automatically.
- Untrusted root – Self‑signed certificates trigger warnings unless explicitly trusted.
Use openssl s_client -connect example.com:443 -showcerts to inspect the chain a server presents.
Practical Debugging: Inspecting a TLS Connection
When HTTPS misbehaves, these commands help:
# Check certificate details and chain
openssl s_client -connect example.com:443 -servername example.com -showcerts
# Test TLS versions and ciphers
nmap --script ssl-enum-ciphers -p 443 example.com
# From the browser: open DevTools → Security tab
Look for errors like UNABLE_TO_VERIFY_LEAF_SIGNATURE (missing intermediate) or ERR_CERT_COMMON_NAME_INVALID (hostname mismatch).
Common Pitfalls and Best Practices
- Mixed content – Loading HTTP resources on an HTTPS page breaks the padlock. Use relative URLs or HTTPS everywhere.
- HSTS – Send
Strict-Transport-Securityto force HTTPS and prevent downgrade attacks. - OCSP Stapling – Lets the server include revocation proof, reducing handshake latency.
- TLS 1.3 – Prefer it for speed and security; disable TLS 1.0/1.1.
- Certificate renewal – Automate with Let's Encrypt and set reminders.
HTTPS is not optional. Search engines rank secure sites higher, and browsers mark HTTP as “Not Secure”.
FAQ
What is the difference between TLS and SSL?
SSL is the predecessor of TLS. Modern “SSL” certificates actually use TLS protocols. TLS 1.2 and 1.3 are the secure versions; SSL versions are deprecated and should not be used.
Does HTTPS slow down my site?
With TLS 1.3 and session resumption, the overhead is minimal—often a few milliseconds. The security benefits far outweigh the cost. Use HTTP/2 or HTTP/3 to further reduce latency.
How do I fix “certificate chain incomplete” errors?
Configure your server to send the full chain, including intermediate certificates. Most CA providers supply a bundle file; point your web server (e.g., Nginx ssl_certificate) to the concatenated certificate and intermediate files.
Need to analyze server logs for TLS errors or performance issues? Try our Nginx Log Analyzer to quickly parse and visualize access logs.