Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Module 1 - Web Security Foundations Web Security Web Security: From Zero to Secure Apps

HTTPS & TLS Explained: How Your Browser Secures Every Connection

Reviewed & accurate
AI Summary

What You Will Learn

INTERMEDIATE
  • The TLS handshake — step by step, in plain English
  • Cipher suites & forward secrecy (why it matters post-Snowden)
  • Common TLS misconfigurations that still bite teams in 2026

What HTTPS Actually Does

HTTPS = HTTP over TLS. TLS provides three guarantees: confidentiality (data is encrypted), integrity (data can't be modified in transit), and authentication (you're really talking to imcseian.com, not an attacker). Without TLS, none of those hold.

How TLS achieves this: a handshake where browser and server agree on encryption keys (using public-key cryptography), then encrypted communication using those keys. The handshake takes 1-2 round trips (~50-100ms) on first connection, then is cached for subsequent ones.

The TLS 1.3 Handshake (Simplified) Browser Server 1. ClientHello\n(supported ciphers,\nrandom number) 2. ServerHello\n(cipher choice, cert,\npublic key) 3. Browser verifies cert\n4. Browser encrypts\npre-master secret 5. Both derive\nsame session key\n6. Encrypted traffic! TLS 1.3: 1 round trip. Older TLS 1.2: 2 round trips.
TLS handshake: browser and server securely agree on a session key.

The Handshake in Detail

  1. ClientHello: browser sends list of ciphers it supports, a random number, and the SNI (Server Name Indication — which site it wants).
  2. ServerHello: server picks one cipher, sends its certificate (proving it's really imcseian.com), and a random number.
  3. Key exchange: browser generates a pre-master secret, encrypts with server's public key (from cert). Both sides derive the same session key.
  4. Encrypted communication: all subsequent traffic uses the session key with symmetric encryption (AES-GCM).

Cipher Suites: What They Mean

A cipher suite is a string like TLS_AES_128_GCM_SHA256. It defines three things: the key exchange (how session keys are derived), the bulk encryption (how traffic is encrypted), and the message authentication (how tampering is detected).

ComponentModern ChoiceWhyAvoid
Key exchangeECDHE (Elliptic Curve Diffie-Hellman Ephemeral)Forward secrecy — even if private key leaks, old traffic stays encryptedRSA key exchange (no forward secrecy)
Bulk encryptionAES-GCM or ChaCha20-Poly1305Authenticated encryption — detects tamperingAES-CBC (vulnerable to padding oracle)
AuthenticationSHA-256 or SHA-384Standard hashMD5, SHA-1 (broken)
Why Forward Secrecy Matters
Without forward secrecy (old RSA key exchange), if an attacker records all your encrypted traffic today and steals your private key in 5 years, they can decrypt everything. With ECDHE (forward secrecy), the session key is ephemeral — there's no key to steal later. Post-Snowden, this is non-negotiable.

TLS 1.3 vs TLS 1.2

AspectTLS 1.2TLS 1.3 (2018)
Handshake round trips21 (faster)
Forward secrecyOptional (often missing)Required
Weak ciphersAllows AES-CBC, RC4, MD5Removed (only AEAD ciphers)
RenegotiationAllowed (vulnerable)Removed
Status in 2026Still 50% of internetRequired for new apps

Common TLS Misconfigurations

  1. Allowing HTTP: even if HTTPS works, allowing HTTP means users can be SSL-stripped. Use HSTS header to force HTTPS.
  2. Weak cipher suites: allowing TLS 1.0/1.1, RC4, AES-CBC. Modern scanners flag these. Disable in Nginx/Apache config.
  3. Self-signed certs: browsers warn users. Use Let's Encrypt (free) or paid CAs.
  4. Missing intermediate cert: some clients fail silently. Always include full chain.
  5. Long cert lifetimes: 1+ year certs mean if stolen, long exploit window. Use 90-day Let's Encrypt certs with auto-renewal.
  6. No HSTS header: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload — tells browser to always use HTTPS for a year.
  7. No OCSP stapling: clients must check revocation status, adding latency. Enable OCSP stapling on server.

Setting Up HTTPS with Let's Encrypt

letsencrypt.shbash
# Install certbot (works with Nginx, Apache, or standalone)
sudo apt install certbot python3-certbot-nginx

# Get a free 90-day cert for your domain
sudo certbot --nginx -d imcseian.com -d www.imcseian.com

# Certbot auto-edits Nginx config to:
# - Listen on 443 with the cert
# - Redirect HTTP → HTTPS
# - Set HSTS header
# Auto-renewal cron is set up automatically

# Test your setup at https://www.ssllabs.com/ssltest/
# Aim for A+ rating

Nginx TLS Configuration (Production)

nginx_tls.confnginx
# /etc/nginx/sites-available/imcseian.com
server {
    listen 443 ssl http2;
    server_name imcseian.com;

    ssl_certificate /etc/letsencrypt/live/imcseian.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/imcseian.com/privkey.pem;

    # Modern TLS configuration (Mozilla intermediate, 2026)
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
    ssl_prefer_server_ciphers off;

    # HSTS (force HTTPS for 1 year, including subdomains)
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 1.1.1.1 8.8.8.8 valid=300s;
}

# Redirect HTTP → HTTPS
server {
    listen 80;
    server_name imcseian.com;
    return 301 https://$host$request_uri;
}

Testing Your TLS Setup

Two free tools every security engineer should bookmark:

🌍 REAL WORLD: Let's Encrypt Saved the Internet
Before 2015, TLS certs cost $50-$500/year and required manual setup. ~50% of websites had no HTTPS. Let's Encrypt launched in 2015 with free 90-day certs and automated renewal. By 2026, 85% of websites have HTTPS. The remaining 15% are mostly abandoned sites. Free certs + automation = mass HTTPS adoption.
Check your own site at ssllabs.com/ssltest/. What's your grade?
If below A, identify the issues (probably: weak ciphers, no HSTS, no OCSP stapling).
Set up Let's Encrypt with certbot — free, automated, 90-day renewal.
Add HSTS header. Submit to https://hstspreload.org for browser preloading.
Bonus: test at observatory.mozilla.org. Fix the top 3 issues.

🎯 Key Takeaways

  • HTTPS = HTTP over TLS. Provides confidentiality, integrity, and authentication.
  • TLS handshake: client/server agree on cipher, exchange keys, encrypt traffic.
  • Forward secrecy (ECDHE) — even if private key leaks, old traffic stays encrypted. Required in 2026.
  • TLS 1.3 (2018) is faster, more secure, mandatory for new apps. TLS 1.0/1.1 must be disabled.
  • Let's Encrypt: free 90-day certs with auto-renewal. Use certbot.
  • Always add HSTS header to force HTTPS. Submit to preload list for browser-level protection.
  • Test at ssllabs.com/ssltest/ — aim for A+ rating.

🧠 Quick Check

Q1. What's 'forward secrecy' and why does it matter?
→ With ECDHE key exchange, session keys are ephemeral. If your private key leaks tomorrow, attackers can't decrypt old recorded traffic. Without it (RSA key exchange), one key compromise = full historical decrypt.
Q2. Why is TLS 1.3 better than TLS 1.2?
→ TLS 1.3: (1) 1 round trip vs 2 (faster), (2) requires forward secrecy, (3) removed weak ciphers (AES-CBC, RC4, MD5), (4) removed renegotiation (vulnerable). Mandatory for new apps in 2026.
Q3. What does the HSTS header do?
→ Strict-Transport-Security tells the browser to always use HTTPS for your domain for N seconds. Prevents SSL strip attacks where attacker downgrades to HTTP. Submit to hstspreload.org for browser-level preloading.
Previously: Previously: Lesson 02 covered HTTP basics.
Today: Today: you learned TLS handshake, cipher suites, and how to set up HTTPS properly.
Next: Next: Lesson 04 covers the browser security model — SOP, CORS, CSP.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments