Skip to content

Web security basics · Part 6 of 10

HTTPS, TLS and HSTS: what the padlock actually promises

TLS encrypts traffic and proves which server you reached. Certificates, redirects and HSTS make sure browsers never fall back to plain HTTP.

· 2 min read

securitytls

HTTPS is HTTP carried inside TLS. The padlock promises three things: nobody on the network can read the traffic, nobody can change it unnoticed, and you are talking to the server that owns the domain name.

What a certificate does

A server presents a certificate that binds its domain name to a public key, signed by a certificate authority that browsers trust. During the handshake the client checks the signature, the name, the expiry date and the chain, then both sides agree on temporary keys for the session. Modern TLS 1.3 does this in one round trip.

What HTTPS does not promise

It does not mean the site is honest, only that you reached the domain you typed. It does not protect the server from attacks such as SQL injection, and it does not hide which domain you visit from the network.

Redirect, then HSTS

Many users type a plain http:// address. A redirect to HTTPS helps, but that first request travels unprotected, so an attacker in the middle can interfere. HTTP Strict Transport Security (HSTS) fixes this: the server tells the browser, over HTTPS, to use only HTTPS for this domain for a period.

Code
Strict-Transport-Security: max-age=31536000; includeSubDomains

After one visit, the browser upgrades every request itself, even if the user types http://. Start with a short max-age while testing, because a mistake locks you in for the whole period.

A short checklist

  1. Serve every page and asset over HTTPS, so there is no mixed content.
  2. Keep TLS 1.2 as the minimum and prefer 1.3.
  3. Automate certificate renewal, for example with the ACME protocol used by Let's Encrypt, and monitor expiry.
  4. Mark cookies Secure.
  5. Send HSTS once everything works over HTTPS.
shell
# Inspect what a server presents (certificate subject, issuer and expiry).
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -issuer -dates

Takeaway

HTTPS gives confidentiality, integrity and server identity. Automate certificates, redirect HTTP, and add HSTS so browsers never downgrade.

A knowledge article, drafted with AI assistance and checked with automated tests. It is general background, not a description of my own experience or of any client's work.

Comments

Leave a comment

No account or email needed. Comments appear after review. A one-way hash of your IP address is kept for 30 days to fight spam, then erased.