Skip to content
6 min read·Lesson 4 of 10

HTTP and TLS

Understand how HTTP works, what HTTPS adds on top of it, how the TLS handshake provides encryption and authentication, and what certificates do.

HTTP is the application protocol that powers the web. Understanding it — including the status codes, headers, and how HTTPS secures it — is essential for any cloud or backend engineer.

HTTP Basics

HTTP (HyperText Transfer Protocol) is a stateless, request-response protocol. A client sends a request, a server responds. The server doesn't remember previous requests (cookies and sessions work around this).

HTTP Request Structure

GET /api/users/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGci...
Accept: application/json
User-Agent: Mozilla/5.0...

HTTP Methods

MethodPurposeIdempotent?
GETRetrieve resourceYes
POSTCreate resource / submit dataNo
PUTReplace resource entirelyYes
PATCHPartially update resourceDepends
DELETERemove resourceYes
HEADGET but response body omittedYes
OPTIONSQuery supported methods (CORS preflight)Yes

HTTP Status Codes

RangeCategoryCommon Examples
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirect301 Moved Permanently, 302 Found, 304 Not Modified
4xxClient error400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
5xxServer error500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

Important HTTP Headers

HeaderDirectionPurpose
Content-TypeBothMIME type of body (application/json, text/html)
AuthorizationRequestBearer token, Basic auth
Cache-ControlBothCaching directives (max-age, no-cache)
X-Forwarded-ForRequestOriginal client IP (set by proxies and LBs)
CORS headersResponseAccess-Control-Allow-Origin etc.
Strict-Transport-SecurityResponseForce HTTPS (HSTS)
X-Content-Type-OptionsResponsePrevent MIME sniffing (nosniff)

HTTP/2 and HTTP/3

  • HTTP/1.1: One request per connection (or keep-alive with pipelining issues)
  • HTTP/2: Multiplexing — multiple requests over one TCP connection; header compression; used by most modern APIs and CDNs
  • HTTP/3: Based on QUIC (UDP) — eliminates TCP head-of-line blocking; faster on unreliable networks

TLS (Transport Layer Security)

HTTPS is HTTP over TLS. TLS provides three things:

  • Encryption: Data is encrypted in transit — cannot be read by a network observer
  • Integrity: Any tampering with data is detected
  • Authentication: The server's certificate proves you're connected to the real server (not an impostor)

The TLS Handshake (TLS 1.3)

  1. Client sends ClientHello — supported cipher suites, random value, SNI (server name)
  2. Server responds with ServerHello — chosen cipher suite, certificate, random value
  3. Client verifies the certificate against trusted Certificate Authorities
  4. Both sides derive session keys using key exchange (ECDHE)
  5. Encrypted communication begins — all HTTP traffic is now encrypted

Certificates

A TLS certificate contains:

  • The domain name(s) it's valid for (Common Name / Subject Alternative Names)
  • The certificate owner's public key
  • The issuing Certificate Authority (CA)
  • Validity period
  • The CA's digital signature

Certificate Authorities (CAs) like DigiCert, Let's Encrypt, and Sectigo verify you control the domain before issuing a certificate. Let's Encrypt provides free, auto-renewing certificates via the ACME protocol.

SNI (Server Name Indication)

SNI allows a single server IP to host multiple HTTPS domains. During the TLS handshake, the client sends the hostname it's connecting to, allowing the server to present the correct certificate. Without SNI, you'd need one IP per HTTPS domain.

Certificate Management in AWS

  • AWS Certificate Manager (ACM): Free public TLS certificates for AWS resources (ALB, CloudFront, API Gateway). Auto-renews.
  • ACM Private CA: For internal certificates and mTLS
  • cert-manager on Kubernetes: Automates certificate issuance via Let's Encrypt or AWS PCA

Next: TCP and UDP — the two transport protocols, when to use each, and the common ports you need to know.

Key Takeaways

  • HTTP is a stateless request-response protocol; HTTPS adds TLS encryption on top.
  • HTTP methods (GET, POST, PUT, DELETE, PATCH) indicate the intended operation.
  • Status codes are grouped: 2xx success, 3xx redirect, 4xx client error, 5xx server error.
  • TLS provides confidentiality (encryption), integrity (tamper detection), and authentication (certificates).
  • SNI allows multiple HTTPS sites on one IP; certificates are issued by Certificate Authorities.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →