Most API gateways authenticate callers with API keys or JWTs — shared secrets that get stolen, rotated lazily, or leaked into logs. Certificate-based mutual TLS (mTLS) eliminates that class of risk entirely: every client proves cryptographic identity on every request, and there is no bearer token to exfiltrate. Here is how to build a minimal zero-trust gateway in Go that enforces it.
Why API Keys Keep Failing
API keys work until they don't. They're long-lived, embedded in environment variables, accidentally committed to repos, passed through logging middleware, and shared across services. The OWASP API Security Top 10 consistently ranks broken authentication as the top risk, and API key misuse is a major contributor.
A client certificate solves these problems at the transport layer:
Certificates can't be replicated without the private key
Revocation is built in (via CRL or OCSP)
Identity is tied to a cryptographic keypair, not a string that can be copied with Ctrl+C
The tradeoff: you need a PKI.…