When you visit a site over HTTPS, your browser and the server perform a cryptographic handshake in about 100 milliseconds. Hereβs every step.
The problem HTTPS solves
HTTP sends everything in plain text. Anyone on the same network (coffee shop WiFi, your ISP, a compromised router) can read your passwords, cookies, and data. HTTPS encrypts the connection so only your browser and the server can read the traffic.
The TLS handshake (simplified)
Step 1: Client Hello
Your browser sends: βHi, I want a secure connection. I support these encryption methods: [list]. Hereβs a random number.β
Step 2: Server Hello
The server responds: βLetβs use this encryption method. Hereβs my SSL certificate and another random number.β
Step 3: Certificate verification
Your browser checks the certificate:
- Is it signed by a trusted Certificate Authority (CA)?
- Is it expired?
- Does the domain name match?
- Is it revoked?
Your OS and browser ship with a list of ~150 trusted CAs. If the certificate chains back to one of them, itβs trusted.
Step 4: Key exchange
This is the clever part. Your browser and the server need to agree on an encryption key, but they canβt send it in plain text (someone might be watching).
They use Diffie-Hellman key exchange: both sides generate a shared secret by exchanging public values. Even if someone captures the entire exchange, they canβt compute the shared secret. The math makes it computationally impossible.
Step 5: Symmetric encryption begins
Both sides now have the same secret key. All further communication is encrypted with fast symmetric encryption (AES-256-GCM typically).
Why not use the certificateβs public key for everything? Because asymmetric encryption (RSA/ECDSA) is ~1000x slower than symmetric encryption (AES). The handshake uses asymmetric crypto once to establish a shared key, then switches to symmetric for speed.
The full timeline
Browser Server
β β
βββ Client Hello βββββββββββββββ>β (1ms)
β<ββββββββββββ Server Hello ββββββ€ (1ms)
β<ββββββββββββ Certificate βββββββ€
βββ Verify cert (local) ββββββββββ (5ms)
βββ Key Exchange βββββββββββββββ>β (2ms)
β<ββββββββββββ Key Exchange ββββββ€ (2ms)
βββ Finished βββββββββββββββββββ>β (1ms)
β<ββββββββββββββββ Finished ββββββ€ (1ms)
β β
β βββ Encrypted connection βββ β
β β
βββ GET /page (encrypted) ββββββ>β
β<ββββ Response (encrypted) ββββββ€
Total handshake: ~50-100ms. After that, encryption adds <1ms per request.
What the padlock icon means
The padlock in your browser means:
- The connection is encrypted (nobody can read the traffic)
- The server proved its identity via a certificate
- The data hasnβt been tampered with (integrity check)
It does NOT mean:
- The website is safe or trustworthy
- The website wonβt steal your data
- The website is legitimate (phishing sites can have HTTPS too)
Why Letβs Encrypt changed everything
Before 2015, SSL certificates cost $50-300/year. Letβs Encrypt made them free and automated. Thatβs why HTTPS went from ~30% of web traffic in 2015 to ~95% today.
# Get a free certificate
sudo certbot --nginx -d yourdomain.com
# Auto-renews every 90 days
Common HTTPS mistakes
Mixed content. Your page loads over HTTPS but includes an image or script over HTTP. The browser blocks it or shows a warning. Fix: use relative URLs or https:// everywhere.
Expired certificates. Letβs Encrypt certificates last 90 days. If auto-renewal breaks (server misconfiguration, DNS change), your site shows a scary βNot Secureβ warning. Fix: set up a cron job or use certbotβs built-in timer, and monitor with a service like UptimeRobot.
Self-signed certificates in production. Self-signed certs work for local development but browsers donβt trust them. Users see a full-page warning. Thereβs no reason to use self-signed certs in production when Letβs Encrypt is free.
Not redirecting HTTP to HTTPS. If someone types http://yoursite.com, they should be automatically redirected to https://. Without this, some users browse your site unencrypted without knowing it.
server {
listen 80;
server_name yoursite.com;
return 301 https://$server_name$request_uri;
}
TLS versions matter
TLS 1.0 and 1.1 are deprecated and have known vulnerabilities. Modern servers should only support TLS 1.2 and 1.3. TLS 1.3 is faster (one fewer round trip in the handshake) and more secure (removed weak cipher suites entirely).
You can check what your server supports at ssllabs.com/ssltest.
The one-sentence summary
HTTPS uses a brief asymmetric handshake to establish a shared secret, then encrypts everything with fast symmetric encryption β so your data is unreadable to anyone except your browser and the server.
Related: What is HTTPS? Β· SSL Certificate Expired β fix Β· SSL Handshake Failed β fix Β· How JWT Actually Works