Skip to content
Lesson: HTTPSSwitch
← Security Operations

Security investigations

HTTPS

Understand what TLS protects when you use HTTPS, and what it does not.

Plain HTTP travels as readable text. Anyone able to observe the network path can read or alter it. HTTPS is HTTP carried over TLS (Transport Layer Security), which protects the connection.

Three protections

  • Confidentiality: observers cannot read the contents.
  • Integrity: changes in transit are detected.
  • Authentication: the client can check, using a certificate, that it reached a server for the requested name.

The path, headers, cookies and body are encrypted. An observer can still see the IP addresses, roughly how much data moves, and often the server name, which is commonly sent unencrypted during the handshake in a field called SNI.

Watch a handshake

bash
$ curl -v https://example.com/ -o /dev/null
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* Server certificate:
*  SSL certificate verify ok.
< HTTP/2 200

This is shortened, and wording differs between curl versions and TLS libraries. TLS 1.2 and 1.3 are the versions to use today. TLS 1.0 and 1.1 are formally deprecated.

Redirect and HSTS

Servers usually answer plain HTTP on port 80 with a redirect to HTTPS on port 443:

bash
$ curl -I http://shop.example.com/
HTTP/1.1 301 Moved Permanently
Location: https://shop.example.com/

The first plain request is still exposed. The Strict-Transport-Security header, called HSTS, tells a browser to use only HTTPS for that site for a set time:

text
Strict-Transport-Security: max-age=31536000

Browsers honour it only when received over HTTPS.

What HTTPS does not do

HTTPS protects data in transit. It does not make a site honest or safe. A scam site can have a valid certificate. It also does not fix weak passwords, missing permission checks or bugs in the application, and data stored on the server is not encrypted by TLS.

Do not "fix" certificate errors with curl -k or by clicking through warnings. -k turns off verification, so you no longer know who you are talking to.

Try it

Run curl -I against http:// and https:// versions of a site you manage. Look for a redirect and the HSTS header. Then read the TLS version with curl -v. Basic network ideas are covered in the networking basics guide.

Check your understanding

HTTPS

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.