Skip to main content

đź”’ HTTPS

A sealed envelope instead of postcard

The Armored Truck Analogy

Transporting valuables:

Regular truck (HTTP): Anyone can see what's inside. Anyone can tamper with the cargo.

Armored truck (HTTPS): Contents are locked and sealed. Any tampering is immediately visible.

HTTPS is an armored truck for your web traffic. Your data travels encrypted (and integrity-protected), with server identity checked via certificates.


HTTP vs HTTPS

AspectHTTPHTTPS
ProtocolUnencryptedTLS encrypted
Port80443
URLhttp://https://
SecurityNoneEncrypted + authenticated
Modern useLegacy, redirectsCommon default

What HTTPS Protects

1. Confidentiality

Without HTTPS:
  Your password: secret123
  Anyone on the network can see it!

With HTTPS:
  Your password: [encrypted blob]
  Your browser and the server can read it (after decrypting).

2. Integrity

Without HTTPS:
  You see: "Transfer $100 to Alice"
  Attacker changes to: "Transfer $1000 to Attacker"
  Bank receives: "Transfer $1000 to Attacker"

With HTTPS:
  Any modification detected.
  The connection is designed to detect tampering.

3. Authentication

Without HTTPS:
  Is this really mybank.com?
  Could be an attacker's fake site.

With HTTPS:
  The server presents a certificate for its hostname.
  The browser validates it and connects to the intended host (assuming the user didn’t click through warnings).

How HTTPS Works

The TLS Handshake (Simplified)

1. Browser connects to server port 443

2. Server sends its certificate
   "Here's proof I'm really example.com"

3. Browser verifies certificate
   Signed by trusted authority?
   Not expired?
   Domain matches?

4. Key exchange
   Browser and server agree on encryption keys

5. Encrypted communication begins
   All data now encrypted

What You See

đź”’ https://example.com

Lock icon = Valid certificate, encrypted connection

⚠️ Warning
  HTTP, or invalid certificate/validation error

Certificates

What's in a Certificate

Domain: example.com
Organization: Example Inc.
Issued by: Let's Encrypt
Valid: <start-date> - <end-date>
Public key: [crypto data]
Signature: [CA's signature]

Certificate Chain of Trust

Root CA (trusted by your browser/OS)
    ↓ signs
Intermediate CA
    ↓ signs
Site's Certificate

Trust flows from root to your site.

Getting a Certificate

Free: Let's Encrypt
  Automated
  Short-lived certificates
  Auto-renewal

Paid: DigiCert, Comodo, etc.
  Longer validity
  Extended validation
  Warranty

Browser Behavior

Valid HTTPS

đź”’ Encrypted connection

Your connection to this site is encrypted.
This helps protect passwords and personal data in transit.

It doesn't tell you whether the site itself is trustworthy.

Invalid/Missing HTTPS

⚠️ Warning

Browser warns users.
Some features disabled (geolocation, etc.).
Users lose trust.

Certificate Errors

â›” Your connection is not private

Expired certificate
Wrong domain
Self-signed (not trusted)

Proceed anyway? (Usually don't!)

Why Every Site Needs HTTPS

It's Not Just for Login Pages

Old thinking:
  "Encrypt login and payment pages"

Modern reality:
  Encrypt as much as practical

Why?
  - Wi-Fi can be sniffed anywhere
  - ISPs can inject ads/tracking
  - Users expect encrypted connections
  - Google ranks HTTPS higher
  - Browser features require HTTPS

Features That Require HTTPS

Progressive Web Apps (PWAs)
Service Workers
Geolocation
Camera/microphone access
Push notifications
HTTP/2

Without HTTPS, many modern browser features won't work.

(Some exceptions exist, like localhost during development.)

Setting Up HTTPS

With Let's Encrypt

1. Install certbot:
   apt install certbot python3-certbot-nginx

2. Get certificate:
   certbot --nginx -d example.com -d www.example.com

3. Certificate issued in seconds!

4. Auto-renewal runs automatically

Redirect HTTP to HTTPS

All HTTP requests → Redirect to HTTPS

User visits: http://example.com
Redirected to: https://example.com

Try not to let users stay on HTTP.

HSTS (HTTP Strict Transport Security)

Header tells browsers:
  "Prefer HTTPS for this site"

Strict-Transport-Security: (max-age and other directives)

Now browser automatically upgrades to HTTPS.

Common Mistakes

1. Not Redirecting HTTP

Both HTTP and HTTPS work?
Users might accidentally use HTTP.
Typically redirect HTTP to HTTPS.

2. Mixed Content

HTTPS page loads HTTP image or script.
Browser blocks or warns.
Check all resources are HTTPS.

3. Expired Certificates

Certificate expires → Site shows warnings/errors.
Users see scary warning.
Set up auto-renewal!

4. Not Including All Domains

Certificate for: www.example.com
User visits: example.com
Certificate error!

Include all variations (with/without www).

FAQ

Q: Does HTTPS slow down my site?

Negligibly. TLS overhead is tiny. HTTP/2 (which requires HTTPS) is actually faster.

Q: Is HTTPS expensive?

Let's Encrypt is free. Paid certificates vary in price.

Q: Do I need HTTPS for a static site?

It’s strongly recommended. Even static sites can be tampered with over HTTP, and some browser features expect HTTPS.

Q: What about internal/development sites?

Use HTTPS there too. It's easy with mkcert or self-signed certs for dev.


Summary

HTTPS encrypts web traffic using TLS, protecting confidentiality, integrity, and authenticating the server.

Key Takeaways:

  • HTTP + TLS = HTTPS
  • Encrypts all data in transit
  • Certificates prove server identity
  • Let's Encrypt = free HTTPS
  • Usually redirect HTTP to HTTPS
  • Most websites should use HTTPS

HTTPS is the modern default for most of the web.

Leave a Comment

Comments (0)

Be the first to comment on this concept.

Comments are approved automatically.