← Course Index

HTTPS & TLS — Why and How

~20 min · Foundations · Glossary →

Ref
Primary Source
Cloudflare Learning Center — What is TLS?

The clearest explanation of the TLS handshake, certificates, and why HTTPS matters. Read this to understand what Certbot is actually doing for you. cloudflare.com/learning →

Why Every Site Needs HTTPS

HTTP sends data as plaintext. Anyone on the same network (your ISP, a coffee shop router, a government) can read and modify every request — including passwords, session tokens, and API keys. HTTPS encrypts the connection using TLS (Transport Layer Security).

In 2025, HTTP is not optional. Browsers mark HTTP sites as "Not Secure." Google penalises them in search rankings. Many APIs refuse to communicate over HTTP. You will always use HTTPS.

💡 TLS vs SSL

SSL is the old, insecure protocol. TLS is its successor. When people say "SSL certificate" they mean a TLS certificate. The terms are used interchangeably in practice — the protocol underneath is always TLS 1.2 or 1.3 in 2025.

The TLS Handshake (Simplified)

When your browser connects to https://yourapp.com, this happens before any data is exchanged:

  1. Client Hello — browser says "I support TLS 1.3, here's a random number"
  2. Server Hello — server picks a cipher suite, sends its certificate
  3. Certificate verification — browser checks: is this cert signed by a trusted CA? Is it for this domain? Is it expired?
  4. Key exchange — both sides use asymmetric crypto to agree on a shared symmetric key
  5. Encrypted data — all subsequent communication uses the symmetric key (fast)
🔑 Key concept

The certificate proves identity (this server really is yourapp.com). The encryption protects privacy (nobody can read the data). Both are required for HTTPS to be trustworthy.

Certificates — The Identity Proof

A TLS certificate is a file that says: "I certify that this public key belongs to yourapp.com" — signed by a Certificate Authority (CA) that browsers trust. Common CAs include Let's Encrypt (free), DigiCert, Comodo, and Amazon ACM.

Certificate Types

TypeCoversUse case
DV (Domain Validated)yourapp.com, *.yourapp.com99% of web apps — Let's Encrypt is DV
OV (Organization Validated)Same + org identity verifiedCorporate sites that want to show org name
EV (Extended Validation)Same + rigorous vettingBanks, payment processors (mostly obsolete)
Wildcard (*.domain.com)All subdomainsapi.yourapp.com, cdn.yourapp.com, etc.

Let's Encrypt — Free Certificates

Let's Encrypt is a non-profit CA that issues free DV certificates. It's automated via the ACME protocol. The certbot tool handles everything: requesting, validating, issuing, and renewing certificates automatically.

# Install Certbot (Ubuntu with snap)
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

# Get a certificate + auto-configure Nginx
sudo certbot --nginx -d yourapp.com -d www.yourapp.com

# Renew all certificates (runs automatically via cron/systemd)
sudo certbot renew

# Test the renewal process without actually renewing
sudo certbot renew --dry-run

# List all certificates
sudo certbot certificates

After running certbot --nginx, Certbot modifies your Nginx config to add SSL and set up HTTP→HTTPS redirects automatically. Certificates expire after 90 days — Certbot renews them automatically at 30 days before expiry.

⚠️ Rate limits

Let's Encrypt limits you to 5 certificate issuances per domain per week. If you're testing, use their --staging flag to get test certs that don't count against the limit.

SSL via Cloudflare (the easier path)

If you use Cloudflare in front of your server, Cloudflare handles the HTTPS between the user and Cloudflare's edge automatically — even if your origin server only speaks HTTP. This is the Flexible SSL mode (not recommended for production).

For production, use Full (Strict) SSL: Cloudflare ↔ User has a Cloudflare cert; Cloudflare ↔ Your server has a Certbot/ACM cert. Both connections are encrypted.

ModeUser→CloudflareCloudflare→ServerRecommendation
OffHTTPHTTPNever
FlexibleHTTPSHTTPNever (data exposed on origin)
FullHTTPSHTTPS (self-signed OK)Avoid (self-signed risks)
Full (Strict)HTTPSHTTPS (valid cert required)✓ Always use this

Check Your Understanding

1. Your Let's Encrypt certificate expires in 25 days. What should you do?
2. You have Cloudflare in front of your server, set to "Flexible" SSL. What's the security problem?
3. What does a TLS certificate actually prove to your browser?
4. You need HTTPS for api.yourapp.com, cdn.yourapp.com, and admin.yourapp.com. What certificate type is most efficient?