Saturday, 5 July 2025

HTTPS and mTLS Explained

HTTPS and mTLS Explained

๐Ÿ” Part 1: Detailed Steps of HTTPS Communication

(Using TLS 1.3, the latest version as of 2025)

HTTPS = HTTP over TLS (Transport Layer Security)
TLS ensures confidentiality, integrity, and authentication between client and server.


⚙️ HTTPS Communication Steps (TLS 1.3)

➤ Step-by-Step TLS 1.3 Handshake:

  1. ๐Ÿง‘‍๐Ÿ’ป Client → Server: ClientHello
    • TLS version (e.g., 1.3)
    • Supported cipher suites
    • Random value (nonce)
    • Key share (for Diffie-Hellman)
    • Extensions (e.g., ALPN, SNI)
  2. ๐ŸŒ Server → Client: ServerHello
    • Chosen cipher suite
    • Random value
    • Server’s X.509 certificate
    • Key share (ECDHE)
    • Optional: Encrypted Extensions
  3. ๐Ÿ”’ Key Exchange & Agreement
    • Both sides perform Ephemeral Diffie-Hellman (ECDHE) to derive a shared symmetric key.
  4. ๐Ÿ” Server Authentication
    • Client verifies the server’s certificate using trusted CA root certificates.
  5. ✅ Client Finished
    • Client sends a Finished message encrypted with the derived key.
    • If successful, this proves the client has derived the correct key.
  6. ✅ Server Finished
    • Server sends its Finished message to complete the handshake.
  7. ๐Ÿ“ก Secure HTTPS Communication Begins
    • All future HTTP traffic is encrypted using the negotiated symmetric key.

๐Ÿ” TLS 1.3 Optimizations Over TLS 1.2

Optimization Benefit
⏱ Fewer Round Trips TLS 1.3 requires only 1-RTT for handshake (vs. 2 in TLS 1.2).
๐Ÿ”’ Forward Secrecy Only uses ephemeral (ECDHE) keys. Prevents compromise if keys are later leaked.
❌ Deprecated Features Removes RSA key exchange, SHA-1, RC4, etc., for stronger security.
⚡ 0-RTT Resumption Enables resumed sessions to send data immediately (with some tradeoffs).

๐Ÿงญ Part 2: What is mTLS (Mutual TLS)?

๐Ÿงฉ Definition

mTLS = Mutual TLS authentication
Unlike normal TLS where only the server is authenticated, mTLS also authenticates the client using a certificate.

๐Ÿ”„ How mTLS Works (with HTTPS)

Phase Description
๐Ÿ” Server Auth Server presents its certificate (as in normal HTTPS).
๐Ÿงพ Client Auth Client also presents its own certificate to the server.
✅ Mutual Verification Both sides verify each other’s certificates (usually X.509).
๐Ÿ”’ TLS Handshake Continues as usual, but both identities are now cryptographically proven.

✅ Benefits of mTLS

Benefit Why It Matters
✅ Strong Client Identity You can trust the client isn’t spoofed—great for API clients, microservices.
๐Ÿ” No Passwords/Secrets Uses certificates instead of shared keys or passwords.
๐Ÿ”„ Mutual Trust Both parties must authenticate each other.
๐Ÿ“œ Auditable and Revocable Easy to revoke access (via CRL or OCSP) and log identities.

๐Ÿ” mTLS vs HTTPS

Feature HTTPS (TLS) mTLS (Mutual TLS)
Server Authenticates ✅ Yes ✅ Yes
Client Authenticates ❌ No ✅ Yes
Use Case Browsers, public sites APIs, internal services, fintech, IoT
Client Credential None (or cookies/token) Client certificate (X.509)

๐Ÿ›  Use Cases for mTLS

  • Microservices talking to each other (zero-trust networks)
  • Banking and payment APIs (e.g., PSD2)
  • Machine-to-machine (M2M) communication
  • IoT devices proving identity to servers
  • Kubernetes (e.g., Istio) with service mesh security

๐Ÿง  Summary

Concept Details
HTTPS = HTTP over TLS Ensures secure communication with encrypted transport
TLS 1.3 handshake One round trip, ECDHE key exchange, no RSA, faster & more secure
mTLS = Mutual TLS Both server and client authenticate each other with certificates
TLS 1.3 benefits Fewer RTTs, stronger crypto, mandatory forward secrecy
mTLS benefit Trusted client identity without relying on passwords or secrets

No comments:

Post a Comment