HTTP and HTTPS
Plain HTTP sends everything as readable text. Anyone between you and the website, such as the operator of a café Wi-Fi network, your internet provider or a compromised router, can read the pages you load and the forms you submit, change them on the way, or pretend to be the website. HTTP gives you no way to tell.
HTTPS is the same HTTP carried inside a protected channel called TLS (Transport Layer Security). TLS gives you three things:
- Encryption, so people in the middle see only scrambled data.
- Authentication, so your browser can check that it is talking to the real server for that domain.
- Integrity, so any change to the data in transit is detected and the connection fails.
TLS and the older SSL
TLS grew out of SSL (Secure Sockets Layer), which Netscape developed in the mid 1990s. People still say "SSL certificate", but every SSL version and the first two TLS versions are now considered insecure.
| Protocol | Year | Status |
|---|---|---|
| SSL 2.0 | 1995 | Insecure, prohibited |
| SSL 3.0 | 1996 | Insecure, prohibited |
| TLS 1.0 | 1999 | Deprecated in 2021 |
| TLS 1.1 | 2006 | Deprecated in 2021 |
| TLS 1.2 | 2008 | In use, secure when configured well |
| TLS 1.3 | 2018 | Current version |
Two kinds of encryption
TLS combines asymmetric and symmetric cryptography. Asymmetric methods use a key pair, a public key anyone can see and a private key the server keeps secret. They are slow, so TLS uses them only at the start: to prove the server's identity and to let both sides agree on a fresh shared secret, usually with elliptic curve Diffie-Hellman (ECDHE). From that secret both sides derive symmetric keys, and the rest of the connection is encrypted with a fast symmetric cipher such as AES-GCM or ChaCha20-Poly1305. Symmetric vs asymmetric encryption explains the difference in more detail.
The TLS handshake, step by step
Every new HTTPS connection starts with a handshake that takes a few milliseconds. In TLS 1.3 it goes like this:
- Client hello. Your browser sends the TLS versions and cipher suites it supports, a random value, the name of the site it wants (so one server can host many sites), and its half of a Diffie-Hellman key exchange.
- Server hello. The server picks the version and cipher suite, sends its own random value and its half of the key exchange. Both sides can now compute the same shared secret, and everything after this point is encrypted.
- Certificate. The server sends its certificate and signs the handshake with its private key, proving it holds the key that matches the certificate.
- Verification. The browser checks the certificate, described below.
- Finished. Both sides send a message that confirms they saw the same handshake, and the page request goes through the encrypted channel.
In TLS 1.2, a common older method had the browser make up a secret, encrypt it with the server's RSA public key and send it over. TLS 1.3 removed that option. With RSA key transport, anyone who later stole the server's private key could decrypt recorded traffic. The temporary Diffie-Hellman keys used in TLS 1.3 give forward secrecy: past sessions stay safe even if the server's long-term key leaks.
TLS 1.3 also needs one round trip between browser and server instead of the two TLS 1.2 needed, and it dropped old, weak ciphers. A returning visitor can even send data in the first message (0-RTT), at the cost of some protection against replayed requests.
Certificates and certificate authorities
A certificate ties a public key to a domain name. It contains:
- the domain names it covers, and sometimes the organization behind them
- the server's public key
- the issuer, the certificate authority (CA) that vouches for it
- the dates it is valid from and until
- a serial number and the CA's digital signature over all of the above
When your browser checks a certificate, it confirms the domain matches the site you asked for, the dates are current, the certificate has not been revoked, and the CA's signature is valid.
The chain of trust
Browsers and operating systems ship with a list of trusted root CA certificates. Root CAs rarely sign website certificates directly. They sign intermediate certificates, and the intermediates sign the website's certificate:
Root CA certificate built into your browser or OS
└ Intermediate certificate signed by the root
└ Website certificate signed by the intermediateThe browser follows the signatures up the chain until it reaches a root it trusts. If any link fails, you see a certificate warning. Each signature is made over a hash of the certificate, which is why certificates moved from SHA-1 to SHA-256. Digital signatures explained shows how that signing works.
Validation levels
| Type | What the CA checks |
|---|---|
| Domain validated (DV) | That the applicant controls the domain. Most sites use DV, often free from Let's Encrypt. |
| Organization validated (OV) | Domain control plus basic checks on the organization. |
| Extended validation (EV) | A stricter check of the legal entity. Browsers stopped showing EV differently in the address bar around 2019. |
All three give the same encryption. They differ only in how much the CA checked about who owns the site.
What your browser shows
A padlock or a similar icon means the connection uses HTTPS with a valid certificate. It says nothing about whether the site is honest: phishing sites get certificates too. A "Not secure" label means plain HTTP. A full-page warning means a certificate problem, such as an expired certificate, a wrong domain or an untrusted issuer. Mixed content, an HTTPS page that loads scripts or images over HTTP, is now mostly blocked or upgraded automatically.
Clicking the icon lets you inspect the certificate. Check that it was issued to the domain you meant to visit, by a recognized CA, and that it is in date.
What HTTPS protects against
- Eavesdropping. Someone recording traffic on a shared network sees only encrypted data.
- Man-in-the-middle attacks. Someone who intercepts the connection cannot present a valid certificate for the real domain, so the browser refuses to continue.
- Tampering. Each encrypted record carries an authentication tag, so injected ads, scripts or changed downloads are detected.
- Session hijacking. Login cookies travel encrypted and cannot be copied off the network.
HTTPS does not protect against phishing sites with their own certificates, malware downloaded from a real site, a compromised computer or server, or bugs in the web application itself. Someone on the network can still see which domain you connect to and roughly how much data you transfer.
Security headers that work alongside HTTPS
| Header | What it does |
|---|---|
| Strict-Transport-Security | Tells the browser to use HTTPS for the site from now on, which blocks downgrade attacks to HTTP |
| Content-Security-Policy | Limits where scripts and other resources may load from, which limits cross-site scripting |
| X-Frame-Options | Stops other sites from showing the page in a frame (clickjacking); CSP's frame-ancestors now does the same |
| X-Content-Type-Options | Stops the browser from guessing file types, so a text file can't be run as a script |
Good practice
For users
- Check the domain in the address bar before you type a password or card number.
- Don't click through certificate warnings, especially on public Wi-Fi.
- Keep your browser and operating system updated, since they carry the list of trusted CAs.
For site owners
- Serve every page over HTTPS and redirect HTTP to it.
- Turn on HSTS once everything works over HTTPS.
- Allow TLS 1.2 and 1.3 only, with modern cipher suites.
- Renew certificates automatically. Maximum certificate lifetimes are being shortened in stages, so manual renewal is getting harder to keep up with.
- Load every script, image and font over HTTPS.
What is changing
Certificate Transparency logs record every publicly trusted certificate, so a domain owner can spot certificates issued without permission. DNS over HTTPS encrypts the DNS lookups that used to reveal every site you visited. HTTP/3 runs over QUIC, a transport protocol with TLS 1.3 built in. Browsers and servers have also started adding post-quantum key exchange to the TLS handshake, so that traffic recorded today can't be decrypted by a future quantum computer.
Try it on Cipher Utility
Further reading
- Symmetric vs Asymmetric Encryption: The Difference One shared key or a key pair, and why HTTPS uses both.
- Public Key Cryptography: The Math, Explained Simply How two strangers agree on a secret over a public line.
- Digital Signatures Explained: How They Prove Authenticity How a key pair proves who sent a file and that nobody changed it.