Lion Cipher Lab

Authenticate clients with mutual TLS (mTLS) using nginx and your own CA

Why it matters

Passwords and API keys are secrets that can be stolen, phished, or leaked in a log. A client certificate is different: the private half never leaves the machine that owns it, so presenting a valid one proves 'I am the service I claim to be' in a way a copied string can't. This is how zero-trust internal networks, service-to-service APIs, and many VPNs decide who is allowed to even open a connection. Building the whole thing by hand once — your own CA, a server cert, a client cert, and a server that demands one — turns mTLS from an intimidating buzzword into something you can set up, break,…

What you'll learn

Steps in this lab

  1. TLS in one breath — and what makes it *mutual*
  2. When you'd reach for mTLS — and when you absolutely wouldn't
  3. Make a working folder and a private network for the lab
  4. Build your private Certificate Authority (the trust anchor)
  5. Issue the server's certificate, signed by your CA
  6. Issue a client certificate — the ID card the caller will present
  7. Write the nginx config that DEMANDS a client certificate
  8. Run nginx in Docker with your certs and config
  9. Prove the policy works: a request with NO certificate is rejected
  10. Prove it again: the client certificate gets you in
  11. The reality: rotation, revocation, and why pros don't do this by hand
  12. Clean up

Open the full interactive lab →