Skip to main content

🔒 SSL/TLS

Encrypting data between you and websites

The Sealed Envelope Analogy

Sending a postcard:

  • Anyone handling it can read your message
  • Post office, mail carrier, neighbors...

Sending a sealed envelope:

  • Contents hidden from everyone
  • Only recipient can open it

SSL/TLS is a sealed envelope for internet traffic. It encrypts data between your client and the server you connect to, helping prevent eavesdropping in transit.


SSL vs TLS: What's the Difference?

SSL (older protocol family):
  Original protocol from the early web era
  SSL 1.0, 2.0, 3.0
  Legacy today (SSL 2.0/3.0 are no longer recommended)

TLS (Transport Layer Security):
  Successor to SSL
  TLS 1.0, 1.1, 1.2, 1.3
  TLS 1.2 is widely used; TLS 1.3 is the newest widely deployed version

"SSL" is often used colloquially to mean TLS.
When someone says "SSL certificate," they mean TLS.

What TLS Protects

The Main Goals

1. CONFIDENTIALITY
   Data is encrypted
  Passive eavesdroppers shouldn't be able to read it

2. INTEGRITY
   If data is modified in transit,
   tampering is detected

3. AUTHENTICATION
  The server proves its identity
  (for HTTPS: via a valid certificate for the hostname)

What It Looks Like

Without TLS:
  Username: alice
  Password: (your password)
  → Someone on the network path may be able to see or modify this

With TLS:
  Encrypted blob: 4f8a2c9e7d3b...
  → Looks like noise to anyone without the keys

How TLS Works

The Handshake

Before data can flow, client and server do a "handshake":

1. Client Hello
   "Hi server! I support TLS 1.3, 1.2..."

2. Server Hello
   "Let's use TLS 1.3. Here's my certificate."

3. Certificate Validation
   Client checks: Is this certificate legit?

4. Key Exchange
   Both sides derive shared session keys
   (without revealing them on the wire)

5. Encrypted Connection Established
   Application data is now encrypted and integrity-protected

(In modern TLS, the handshake uses asymmetric cryptography to agree on shared keys; bulk data is then protected with symmetric encryption.)

Visual Flow

Client                              Server
  │                                    │
  │──── Client Hello ────────────────→ │
  │                                    │
  │←─── Server Hello + Certificate ─── │
  │                                    │
  │     (Validate certificate)         │
  │                                    │
  │──── Key Exchange ────────────────→ │
  │←─── Key Exchange ───────────────── │
  │                                    │
  │     [Session keys derived]         │
  │                                    │
  │════ Encrypted traffic ════════════ │

Certificates

What's in a Certificate?

Certificate contains:
  - Domain name (example.com)
  - Organization name
  - Public key
  - Issuer (Certificate Authority)
  - Validity period (start date - end date)
  - Digital signature

Certificate Chain

Root CA (trusted by browsers)
    ↓ signs
Intermediate CA
    ↓ signs
Your site's certificate

Browsers trust your cert because they trust the chain!
If the chain validates to a trusted root and the certificate matches the hostname, the browser treats the connection as authenticated.

Certificate Authorities (CAs)

Trusted CAs:
  - Let's Encrypt (free!)
  - DigiCert
  - Sectigo (formerly Comodo CA)

CAs verify you own the domain before issuing.

TLS Versions

VersionStatusNotes
SSL 3.0❌ LegacySerious vulnerabilities
TLS 1.0❌ LegacyPhased out
TLS 1.1❌ LegacyPhased out
TLS 1.2✅ SupportedStill widely used
TLS 1.3✅ Current-ishFaster, newer defaults

TLS 1.3 Improvements

Faster handshake:
  Full TLS 1.2 handshake: typically 2 round trips
  Full TLS 1.3 handshake: typically 1 round trip
  (Resumed sessions can be fewer; TLS 1.3 also supports 0-RTT data in some cases)

Stronger security:
  Removed many legacy algorithms
  Forward secrecy by default

Common Certificate Types

Domain Validation (DV)

Proves: You control the domain
Validation: Automated (email, DNS record)
Cost: Free (Let's Encrypt) to $$
Visual: 🔒 in browser

Organization Validation (OV)

Proves: Organization identity verified
Validation: Manual verification
Cost: $$
Visual: 🔒 + organization name visible

Extended Validation (EV)

Proves: Extensive organization verification
Validation: Thorough business verification
Cost: $$$
Visual: Modern browsers largely de-emphasize EV UI indicators

Getting a Certificate

Free: Let's Encrypt

1. Install certbot (or similar tool)
2. Run: certbot --nginx -d example.com
3. Certificate issued in minutes!
4. Auto-renewal on a regular schedule

Free and automated.
1. Generate CSR (Certificate Signing Request)
2. Submit to CA with payment
3. Complete validation
4. Receive certificate
5. Install on server

More support, longer validity, warranty.

Certificate Problems

Expired Certificate

Browser: "Your connection is not private"
User: Scared away!

Solution: Auto-renewal (certbot renew)

Wrong Domain

Certificate for: www.example.com
Accessing: example.com

Browser: "Certificate mismatch!"

Solution: Include all domains in certificate (SAN)

Self-Signed Certificate

You signed your own certificate.
Browsers don't trust it.
Warning displayed.

OK for: Development, internal tools
Not OK for: Public websites

Best Practices

1. Use TLS 1.2 or 1.3

Disable older versions.
TLS 1.0 and 1.1 are widely disabled on modern clients.

2. Enable HSTS

HTTP Strict Transport Security
Tells browsers: "Prefer HTTPS for this site"
Prevents downgrade attacks.

Note: HSTS is learned after a successful HTTPS visit (unless you use HSTS preload).

3. Redirect HTTP to HTTPS

http://example.com → https://example.com

Don't let users accidentally use HTTP.

4. Keep Certificates Updated

Expired cert = site errors
Set up auto-renewal or calendar reminders.

Common Mistakes

1. Mixed Content

HTTPS page loading HTTP resources (images, scripts).
Browser may block or warn.
Use HTTPS for all page resources.

2. Not Validating Certificates in Code

verify=False in HTTP clients = BAD
You're accepting any certificate, even fake ones.
Avoid disabling certificate validation in production; for development/internal systems, use a proper trust store or pin/trust a specific internal CA.

3. Weak Cipher Suites

Some old ciphers are known to be weak.
Configure server to use modern ciphers only.
Use tools like Mozilla SSL Config Generator.

FAQ

Q: Is HTTPS the same as TLS?

HTTPS = HTTP over TLS. The "S" means TLS is protecting HTTP traffic.

Q: Does TLS slow things down?

Slightly, but modern TLS is fast. The privacy/integrity benefits usually outweigh the small overhead.

Q: Do I need a certificate for internal apps?

Often yes, especially if any untrusted users/devices can reach it. Anyone on the network path could eavesdrop. Use an internal CA or Let's Encrypt.

Q: What's a wildcard certificate?

Covers *.example.com - one cert for all subdomains.


Summary

SSL/TLS encrypts internet traffic, ensuring confidentiality, integrity, and authentication.

Key Takeaways:

  • TLS = successor to SSL (use TLS)
  • TLS encrypts data in transit
  • Certificates prove server identity
  • Let's Encrypt provides free certificates
  • Use TLS 1.2 or 1.3
  • HTTPS = HTTP + TLS

TLS is a big reason the internet can be used more safely for banking, shopping, and private communication. TLS is a big reason the internet can be used with less risk for banking, shopping, and private communication.

Leave a Comment

Comments (0)

Be the first to comment on this concept.

Comments are approved automatically.