Beginner · Networking for security · topic 10 of 43 · 30 min
HTTP, HTTPS and TLS
Explanation
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).
| Method | Meaning |
|---|---|
| GET | Read something (a page, a file, data) |
| POST | Send data, such as a login form or a payment |
| PUT / PATCH | Update something |
| DELETE | Remove something |
| Status | Meaning | What it can mean in security |
|---|---|---|
| 200 | OK | Success; check whether it should have succeeded |
| 301 / 302 | Redirect | HTTP to HTTPS redirects are normal |
| 401 | Unauthorised: not logged in | Many in a row from one IP = password guessing |
| 403 | Forbidden: logged in but not allowed | Someone trying pages they should not |
| 404 | Not found | Hundreds of 404s = someone probing for hidden files |
| 500 | Server error | Bad input crashed something; possible injection testing |
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"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.
$ 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=LaxHeaders 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
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)
A user who is logged in tries to open /admin and gets a status that means "you are known, but not allowed". Which code?
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=".
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- IP addresses, subnets and CIDRNetworking for security · same module
- HTTP headers and cookiesBackend Development · How the web and backends work
- How web requests work (and why that matters)Ethical Hacking and Penetration Testing (legal labs) · Web application testing: Burp Suite and the basics
- HTTP requests, responses and methodsBackend Development · How the web and backends work
- Sessions and cookiesBackend Development · Authentication and authorization
- An HTTP server with net/httpGo Programming (backend and cloud) · Standard library essentials
Questions people ask about this
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.
HTTP is…Related
Answer: The text-based language browsers and servers use
HTTP is the request/response protocol of the web.
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.
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
- This is the last topic of “Networking for security”. The module exam comes next.
- Module 2 exam: Networking for security · 12 questions · 20 min, without help. 5 topics of this module still to finish first.
- Then the next module, Systems and cryptography. 43 topics left in the course before the final exam.