HTTPS and TLS
Encrypt traffic with TLS, obtain certificates automatically and understand what the handshake proves.
Beginner · about 3 hours · difficulty 2/5
Learn first: HTTP in Depth, Where Backends Run: Hosting Options
TLS (Transport Layer Security) encrypts traffic between client and server and proves the server's identity. HTTPS is simply HTTP over TLS. Every public backend must use it; browsers mark plain HTTP as insecure and many features require HTTPS.
What TLS gives you
- Confidentiality: eavesdroppers cannot read the traffic.
- Integrity: tampering is detected.
- Authentication: the server presents a certificate signed by a trusted Certificate Authority (CA), proving it controls the domain.
How the handshake works (TLS 1.3, simplified)
The client and server agree on a cipher suite and perform a key exchange (ECDHE) to derive shared session keys. The server sends its certificate chain, which the client validates up to a root CA it trusts. Then encrypted application data flows.
In practice
- Get free, automatically renewed certificates from Let's Encrypt via certbot, or let Caddy, your PaaS, load balancer or CDN handle it.
- Terminate TLS at a reverse proxy or load balancer, and decide whether internal hops also need encryption (in zero-trust setups they do, often via mTLS).
- Redirect HTTP to HTTPS and add HSTS so browsers never try plain HTTP again.
- Disable old protocols (SSL, TLS 1.0 and 1.1).
Pitfalls
- Expired certificates are a classic outage. Automate renewal and alert on expiry.
- Disabling certificate verification in HTTP clients "to make it work".
You are ready to move on when your deployed app has an A rating on an SSL test tool, auto-renewing certificates and HSTS enabled.
Key concepts
- Certificates and certificate authorities
- TLS 1.3 handshake
- Let's Encrypt and certbot
- TLS termination at a proxy
- HSTS
- Mutual TLS (mTLS)
Mini project
Put your VPS-hosted app behind Nginx or Caddy with a Let's Encrypt certificate, HTTP to HTTPS redirect and HSTS, then scan it with an online SSL testing tool.
Check yourself
What exactly does a valid TLS certificate prove to the browser, and what does it not prove?
Free resources
- Let's Encrypt documentation (Let's Encrypt)
- MDN: Transport Layer Security (MDN)
- What is TLS? (Cloudflare)