Skip to content

Beginner · Networking for security · topic 10 of 43 · 30 min

HTTP, HTTPS and TLS

Explanation

HTTP is the language browsers and web servers use: requests with methods like GET and POST, and responses with status codes like 200 and 404. HTTPS is HTTP inside TLS, which encrypts the traffic, protects it from changes and proves the server's identity with a certificate. Security headers and cookie flags add more protection.

Why defenders read HTTP

Most business apps, APIs and attacks run over the web. Web server logs, proxy logs and web application firewall alerts are all written in HTTP terms. To read them you need to know requests, responses, status codes, headers and cookies.

Requests and responses

HTTP (Hypertext Transfer Protocol) works as request and response. The browser sends a request; the server sends back a response. Each request has a method, a path and headers (extra lines of information).

MethodMeaning
GETRead something (a page, a file, data)
POSTSend data, such as a login form or a payment
PUT / PATCHUpdate something
DELETERemove something
StatusMeaningWhat it can mean in security
200OKSuccess; check whether it should have succeeded
301 / 302RedirectHTTP to HTTPS redirects are normal
401Unauthorised: not logged inMany in a row from one IP = password guessing
403Forbidden: logged in but not allowedSomeone trying pages they should not
404Not foundHundreds of 404s = someone probing for hidden files
500Server errorBad input crashed something; possible injection testing
output
203.0.113.77 - - [14/Mar/2026:10:21:07 +0530] "POST /login HTTP/1.1" 401 512 "-" "python-requests/2.32"
203.0.113.77 - - [14/Mar/2026:10:21:08 +0530] "POST /login HTTP/1.1" 401 512 "-" "python-requests/2.32"
203.0.113.77 - - [14/Mar/2026:10:21:09 +0530] "POST /login HTTP/1.1" 200 1024 "-" "python-requests/2.32"
A web server access log: repeated 401s from a script, then a 200. A guessed password is likely.

HTTPS and TLS

Plain HTTP sends everything as readable text. Anyone on the same café Wi-Fi or along the path could read or change it. HTTPS is HTTP sent inside TLS (Transport Layer Security). TLS gives three things:

  • Confidentiality: the traffic is encrypted.
  • Integrity: any change on the way is detected.
  • Authentication: the server proves who it is with a certificate signed by a trusted certificate authority.

Current versions are TLS 1.2 and TLS 1.3. The old SSL protocols and TLS 1.0 and 1.1 are deprecated (officially retired) and should be turned off. TLS 1.3 is faster and removed many weak options.

In a simplified TLS handshake, the browser says which versions and ciphers it supports, the server answers with its choice and its certificate, the browser checks the certificate, and both sides agree on fresh session keys. After that, all data is encrypted.

bash
$ curl -sI https://shop.example
HTTP/2 200
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
content-security-policy: default-src 'self'
set-cookie: session=4f9c...; Path=/; Secure; HttpOnly; SameSite=Lax
curl -I shows only the response headers. This site sends good security headers.

Headers and cookies that protect users

  • Strict-Transport-Security (HSTS): tells the browser to use only HTTPS for this site from now on.
  • Content-Security-Policy (CSP): limits where scripts can load from, reducing cross-site scripting.
  • X-Content-Type-Options: nosniff: stops the browser guessing file types.
  • Cookie flags: Secure (only sent over HTTPS), HttpOnly (JavaScript cannot read it, so a script injected by an attacker cannot steal it), SameSite (limits sending the cookie from other sites, which helps against cross-site request forgery).

Common mistakes

  • "It has a padlock, so it is safe." TLS protects the connection, not the honesty of the site.
  • Leaving TLS 1.0 enabled "for old clients".
  • Session cookies without Secure and HttpOnly.
  • Ignoring certificate warnings. In a company, a certificate warning on an internal site can mean someone is intercepting traffic.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

HTTP, HTTPS and TLS · 1/7

Request → Response

Web apps and APIs speak HTTP: the browser sends a request, the server sends a response.

Prefer a video by a teacher? Find free videos on “HTTP vs HTTPS TLS handshake explained simply” on YouTube ↗

In real life: Login guessing in a web log

An e-commerce company's monitoring sees 6,000 POST /login requests returning 401 in one hour, from 40 addresses, all with the same user agent. A few return 200. The SOC blocks the addresses at the web application firewall, forces password resets for the accounts that returned 200, and asks the developers to add rate limiting and MFA. HTTP status codes told the whole story.

Practice (0/3 done)

Task 1 · Question

A user who is logged in tries to open /admin and gets a status that means "you are known, but not allowed". Which code?

Task 2 · Code · Python

Write missing_cookie_flags(set_cookie) that takes a Set-Cookie header value like "session=abc; Path=/; Secure; HttpOnly" and returns a list of the flags from ["Secure", "HttpOnly", "SameSite"] that are missing, in that order. Ignore case. SameSite counts as present if any attribute starts with "samesite=".

Task 3 · Practice

Open your browser's developer tools (F12) on a site you use, go to the Network tab, reload, and click the first request. Write down the status code, the HTTP version, three response headers, and whether the cookies have Secure and HttpOnly.

Quick quiz

Question 1

1.Which TLS versions should a server allow today?

Question 2

2.What does the HttpOnly cookie flag do?

Question 3

3.Hundreds of 404 responses for paths like /backup.zip, /.git/config and /admin.php from one IP suggest…

Question 4

4.What does HSTS tell the browser?

Question 5

5.Which three things does TLS provide?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which TLS versions should a server allow today?

Answer: TLS 1.2 and TLS 1.3

SSL and TLS 1.0/1.1 are deprecated. Use 1.2 and 1.3.

What does the HttpOnly cookie flag do?

Answer: Stops JavaScript in the page from reading the cookie

HttpOnly hides the cookie from scripts, so injected scripts cannot steal the session.

Hundreds of 404 responses for paths like /backup.zip, /.git/config and /admin.php from one IP suggest…

Answer: Someone probing for hidden files

Automated scanners try many common hidden paths, producing many 404s.

What does HSTS tell the browser?

Answer: Use only HTTPS for this site in future

Strict-Transport-Security makes the browser refuse plain HTTP for the site.

Which three things does TLS provide?

Answer: Encryption, integrity and server authentication

TLS encrypts, detects tampering and proves the server's identity with a certificate.

How does the server ask the browser to save a cookie?Related

Answer: With a Set-Cookie response header

The server sends Set-Cookie. After that, the browser sends the value back in the Cookie header.

From HTTP headers and cookies

HTTP is…Related

Answer: The text-based language browsers and servers use

HTTP is the request/response protocol of the web.

From How web requests work (and why that matters)

Which part of an HTTP request carries the JSON data you send?Related

Answer: The body

The body comes after the headers and the empty line, and holds the data.

From HTTP requests, responses and methods

Which cookie flag stops page JavaScript from reading the cookie?Related

Answer: HttpOnly

HttpOnly hides the cookie from document.cookie, so an XSS bug cannot steal the session id.

From Sessions and cookies

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Networking for security”. The module exam comes next.
  2. Module 2 exam: Networking for security · 12 questions · 20 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Systems and cryptography. 43 topics left in the course before the final exam.

← Previous: DNS: the internet's phone book