HTTPS and TLS
How the padlock works: encryption, certificates, and Certificate Authorities
Skills taught: web.https, web.tls, web.certificates, web.encryption-basics
HTTP vs HTTPS
HTTP (plain text):
You → Router → ISP → Internet → Server
Every step can read: "POST /login password=hunter2"
Every step can modify: inject ads, malware, tracking pixels
HTTPS (encrypted):
You → [encrypted tunnel] → Server
All data is encrypted between your browser and the server
Routers, ISPs, and attackers see only: random ciphertext
The server's certificate proves it is who it claims to be
Results without HTTPS:
✗ Passwords readable on public WiFi
✗ Session cookies stealable (cookie theft = account takeover)
✗ ISPs can inject ads or track every page you visit
✗ Attackers can modify page content in transit
How TLS works
Browser Server
│ │
│─── ClientHello ───────────────────►│
│ (TLS version, supported ciphers) │
│ │
│◄── ServerHello + Certificate ───────│
│ (chosen cipher, server's │
│ certificate with public key) │
│ │
│ Browser verifies certificate: │
│ 1. Trusted CA signed it? │
│ 2. Domain name matches? │
│ 3. Not expired? │
│ 4. Not revoked? │
│ │
│─── Encrypted with server's key ───►│
│ (establish shared secret) │
│ │
│◄══ All HTTP data now encrypted ════►│
│ (using fast symmetric key) │
Certificates and Certificate Authorities
A TLS certificate is a digital document that proves: 'I am kernal.dhurta.org, and this public key belongs to me.' But anyone could generate a self-signed certificate claiming to be kernal.dhurta.org. Certificate Authorities (CAs) are trusted third parties that verify domain ownership before signing certificates.
- You generate a private key and a Certificate Signing Request (CSR) for your domain
- A CA (Let's Encrypt, DigiCert, Comodo) verifies you own the domain (by checking DNS records or a file on your server)
- The CA signs your certificate with their private key
- Browsers ship with a list of ~150 trusted root CAs built in
- When a browser sees your certificate, it checks: 'Is this signed by a CA I trust?' → yes → padlock shown
Tip: Let's Encrypt is a free, automated CA. Most hosting providers (Cloudflare, Netlify, Vercel) provision TLS certificates automatically. There is no reason for any site to use HTTP in 2026.
Frequently Asked Questions
Is HTTPS enough to keep my site secure?
HTTPS encrypts data in transit — it prevents eavesdropping and tampering on the network. But it says nothing about what happens at the server: your database can still be hacked, your JavaScript can still have XSS vulnerabilities, your passwords can still be stored in plain text. HTTPS is necessary but not sufficient. It is the floor of web security, not the ceiling.
Does HTTPS slow down my site?
Negligibly, in practice. TLS 1.3 requires only 1 extra round-trip on first connection (vs HTTP's 0), and 0-RTT session resumption eliminates this for returning visitors. The overhead is measured in milliseconds. Modern CPUs handle TLS encryption natively with hardware acceleration. The benefits (security, user trust, SEO) far outweigh the negligible performance cost.