HTTP vs HTTPS: What the S Actually Changes
HTTPS is HTTP inside TLS. Learn the handshake, the certificate, the mixed content problem, and why every site needs it today.
By Velloreth
The relationship
HTTPS is HTTP inside a TLS tunnel.
HTTP request -> TLS encrypt -> the network -> TLS decrypt -> HTTP request
The request and the response are the same. The difference is the transport.
The port is a convention, not the definition: 443 for HTTPS and 80 for HTTP.
What TLS provides
| Property | Meaning |
|---|---|
| Confidentiality | a network observer cannot read the traffic |
| Integrity | a modification is detected |
| Authentication | the client knows the server |
What it does not provide:
- It does not hide the domain name in most cases
- It does not protect against a compromised server
- It does not protect the data at rest
- It does not authenticate the user
The handshake
1. The client sends a hello with the supported versions and ciphers.
2. The server responds with its choice and its certificate.
3. The client verifies the certificate against a trusted root.
4. The two derive a shared key with a key exchange.
5. The connection is established, and the HTTP request is sent.
TLS 1.3 reduces the handshake to one round trip, and it supports a resumption with zero.
The certificate
A document that binds a public key to a domain name.
The chain:
The root CA (in the browser's trust store)
-> an intermediate CA
-> the leaf certificate for example.com
The client verifies:
- The signature chain to a trusted root
- The domain name matches
- The validity dates
- The revocation status
A self-signed certificate is not trusted unless it is installed.
Let’s Encrypt issues a free certificate, and it is the common choice for a small site.
The mixed content
A page over HTTPS that requests a resource over HTTP.
<!-- Blocked on an HTTPS page -->
<script src="http://example.com/app.js"></script>
A modern browser blocks an active resource such as a script, a stylesheet or a fetch.
A passive resource such as an image may be upgraded or warned about.
The fix: load every resource over HTTPS, and use a protocol-relative or an absolute HTTPS URL.
A CSP directive can enforce it.
Content-Security-Policy: upgrade-insecure-requests
HSTS
HTTP Strict Transport Security.
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
It tells the browser to use HTTPS for the domain for a period.
It prevents a downgrade attack, where an attacker redirects the first request to HTTP.
includeSubDomains applies it to every subdomain, which requires every subdomain to support HTTPS.
preload submits the domain to a list built into the browser.
The caution: a long max-age is hard to undo, so start with a short one.
The redirect
A permanent redirect from HTTP to HTTPS.
http://example.com -> https://example.com
A 301 is the permanent redirect, and a browser caches it.
The redirect is the first request, so it is a small window for a downgrade, which HSTS closes.
The performance
The handshake adds a round trip on the first connection.
TLS 1.3 reduces it, and a resumption removes it.
The encryption is fast with hardware support.
A modern site should treat HTTPS as the default, not as a trade-off.
Common mistakes
Mixed content. A blocked resource.
A self-signed certificate in production. A browser warning.
An expired certificate. A hard failure.
No redirect from HTTP. A user reaches the insecure version.
No HSTS. A downgrade window.
A long HSTS max-age before every subdomain works. A lockout.
A certificate for the wrong domain. A warning.
No renewal automation. An expiry.
A secret in a URL. It is in the log and the referrer.
HTTPS assumed to protect the data at rest. It does not.
A quotable summary
HTTPS is HTTP carried inside a TLS connection, and TLS provides confidentiality, integrity and authentication. A certificate binds a public key to a domain and is verified against a trusted root, mixed content is blocked by a modern browser, and HSTS forces HTTPS and closes the downgrade window. The handshake adds a round trip on the first connection, and the encryption itself is fast, so HTTPS is the default rather than a trade-off.
Related reading
For the related topics, see security-headers-guide and encryption-at-rest-vs-transit. For the broader context, content-security-policy-guide and how-cdns-actually-work.