Skip to content
Velloreth
Web Development 4 min read

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

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

PropertyMeaning
Confidentialitya network observer cannot read the traffic
Integritya modification is detected
Authenticationthe 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.

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.

Frequently asked questions

What is the difference between HTTP and HTTPS?
HTTPS is HTTP carried inside a TLS connection. The HTTP request and response are the same, and the difference is that the bytes are encrypted and authenticated. A port is not the difference: 443 is the convention for HTTPS and 80 for HTTP, and either can be used.
What does TLS provide?
Confidentiality, so a network observer cannot read the traffic; integrity, so a modification is detected; and authentication, so the client knows it is talking to the right server. It does not hide the domain name in most cases, and it does not protect against a compromised server.
What is a certificate?
A document that binds a public key to a domain name, signed by a certificate authority. The client verifies the signature against a trusted root, checks the domain, and checks the validity dates. A self-signed certificate is not trusted by a browser unless it is installed.
What is mixed content?
A page loaded over HTTPS that requests a resource over HTTP. A modern browser blocks an active resource such as a script, and it may warn about a passive one such as an image. The fix is to load every resource over HTTPS.
What is HSTS?
HTTP Strict Transport Security, a response header that 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. It should be enabled after HTTPS works on every subdomain.
Does HTTPS make a site slow?
Not meaningfully. The handshake adds a round trip on the first connection, and TLS 1.3 reduces it, and the encryption itself is fast with hardware support. A modern site should treat HTTPS as the default and not as a performance trade-off.