Skip to content

Identity bridge

When TLS ends at the proxy, the backend no longer sees the client’s certificate. The identity bridge carries it across: the proxy authenticates the client, then proves who it is to the backend, without the backend taking part in the client’s handshake.

  1. The client connects. It negotiates X25519MLKEM768 with the proxy and presents the client certificate it already has.
  2. The proxy checks it. It verifies the chain, validity, revocation (CRLs) and proof of the private key, maps the certificate to a principal, and applies the allow list.
  3. The proxy signs an assertion. It’s short-lived, bound to one audience and (over HTTP) one request, and signed with the gateway’s ML-DSA key.
  4. The backend verifies it. It checks the signature, issuer, audience, expiry, request binding and replay, then applies its own authorization.
Terminal window
pqdoctor identity-bridge keygen /etc/pqdoctor/bridge # signing.key + jwks.json (ML-DSA-65)
pqdoctor identity-bridge analyze proxy.toml # which bridge fits each backend
pqdoctor identity-bridge authz --listen 127.0.0.1:9478 \
--jwks /etc/pqdoctor/bridge/jwks.json --audience banking-api --issuer pqdoctor-gateway-01
[listener.client_auth]
mode = "require"
ca = "users-ca.pem"
crl = ["users-crl.pem"] # revocation; `pqdoctor proxy ca revoke DIR --cert F` makes one
[listener.identity]
key = "/etc/pqdoctor/bridge/signing.key"
issuer = "pqdoctor-gateway-01" # iss
audience = "banking-api" # aud: required
ttl = 30 # seconds, 5–300
header = "pq-identity" # http: the header that carries it
allow = ["*@company.internal"] # principals let through (globs); empty: every verified client
[[listener.identity.route]] # http: per-path allow lists, first match wins
path_prefix = "/admin"
allow = ["root@company.internal"]
[[listener.identity.map]] # how a certificate becomes a principal, first match wins
source = "email" # email, uri, dns, ip, cn, fingerprint
match = "*@company.internal"
issuer = "Corp Users CA" # only for certificates from this CA (issuer CN glob)
principal = "{value}" # also {local}, {domain}, {cn}

Without map rules the principal is the first email SAN, else the URI SAN (SPIFFE IDs), else a DNS SAN, else the subject CN.

  • http puts the assertion in pq-identity on every request. Whatever the client sent in that header is removed first. A client the bridge refuses gets 403, and so does a principal a route doesn’t allow.
  • tcp and tunnel-server put it in the PROXY v2 header as TLV 0xE2, once per connection (forward.proxy_protocol = true). nginx reads it as $proxy_protocol_tlv_0xe2, HAProxy as fc_pp_tlv(0xE2). A client the bridge refuses is disconnected.
  • require = false (with client_auth.mode = "optional") lets clients without a certificate through with no assertion. require_pq_client_auth = true refuses clients whose own key isn’t ML-DSA or SLH-DSA.

A JWT (RFC 7519) in JWS compact form (RFC 7515), signed with ML-DSA-44, -65 (default) or -87. The alg names and the AKP key type are the JOSE registrations from draft-ietf-cose-dilithium: pure ML-DSA with an empty context. Node 24 reads these keys natively.

{ "alg": "ML-DSA-65", "typ": "pqdoctor-id+jwt", "kid": "TcO0oVlKB9VCVptYusdCBcML_s6gN2L8kUasQUdLt9g" }
{
"iss": "pqdoctor-gateway-01",
"sub": "alice@company.internal",
"aud": "banking-api",
"iat": 1794500000, "nbf": 1794500000, "exp": 1794500030,
"jti": "kq2m7Hc0V9nXo4o1ZfTq3w",
"amr": ["mtls"],
"cnf": { "x5t#S256": "base64url SHA-256 of the client certificate" },
"htm": "GET",
"htu": "https://api.example/accounts",
"cert": { "email": ["alice@company.internal"], "cn": "alice@company.internal", "issuer_cn": "Corp Users CA" },
"pqd": { "v": 1, "kex": "X25519MLKEM768", "tls": "TLSv1.3", "transport_pq": true,
"client_key": "ec-p256", "client_auth_pq": false, "bridge_alg": "ML-DSA-65" }
}
  • typ is explicit (RFC 8725), so the token can’t be mistaken for another kind of JWT.
  • kid is the RFC 7638 thumbprint of the key. A JWKS entry whose kid isn’t its key’s thumbprint is refused.
  • cnf ties the assertion to the client certificate (RFC 8705). htm and htu tie it to one request (as in RFC 9449). htu is scheme, host and path, with no query.
  • pqd is the evidence: what the transport negotiated, the client key’s algorithm, and which parts are post-quantum.

What the ML-DSA signature proves: that this gateway’s key endorsed the statement. It doesn’t make the client’s own authentication post-quantum. If Alice’s certificate is ECDSA, client_auth_pq is false and stays false. The three levels:

Key exchange Client authentication Identity to the backend
Existing clients Hybrid ML-KEM RSA / ECDSA (classical) ML-DSA assertion
Upgraded clients (proxy ca issue --client --alg ml-dsa-65) Hybrid ML-KEM ML-DSA ML-DSA assertion
Two pqdoctors (proxy wrap, tunnels) Hybrid ML-KEM ML-DSA between the gateways, plus a pinned Ed25519 key (hybrid_auth) Optional

The backend must already trust the gateway’s public key, and it must get jwks.json through provisioning you control: config management or a secrets store. Nothing fetches it from the network. A backend that took it from an untrusted place would trust whoever wrote it.

Every verifier below checks the same things:

  • the key decides the algorithm, never the token;
  • typ, and no crit headers;
  • the signature;
  • issuer and audience;
  • the time window, with 5 s of leeway;
  • a 300 s lifetime cap;
  • the request binding;
  • replay of jti, until expiry. The replay cache is bounded: when it’s full of unexpired entries it refuses rather than forgets.

nginx (auth_request), from integrations/identity-bridge/nginx/identity-bridge.conf:

location / {
auth_request /_pq_auth;
auth_request_set $pq_subject $upstream_http_x_pq_subject;
proxy_set_header X-Remote-User $pq_subject;
proxy_set_header pq-identity "";
proxy_pass http://127.0.0.1:3000;
}
location = /_pq_auth {
internal;
proxy_pass http://127.0.0.1:9478; # pqdoctor identity-bridge authz
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-Method $request_method;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header Host $host;
}

An ML-DSA-65 assertion is about 5.1 KB: keep large_client_header_buffers at 8k or more.

Envoy (ext_authz, HTTP service): run authz with --path-prefix set to the filter’s path_prefix. Allow the x-pq-* answer headers upstream. The whole file is in integrations/identity-bridge/envoy/identity-bridge.yaml. Traefik forwardAuth works the same way: authz reads X-Forwarded-Method and X-Forwarded-Uri.

authz answers 200 with x-pq-subject, x-pq-issuer, x-pq-kid, x-pq-client-cert-x5t-s256, x-pq-client-key, x-pq-client-auth-pq, x-pq-transport-pq, x-pq-key-exchange and x-pq-assertion-jti. Otherwise it answers 401 with x-pq-reason.

An app with nothing in front:

Terminal window
pqdoctor identity-bridge guard --listen 127.0.0.1:8081 --backend 127.0.0.1:3000 \
--jwks jwks.json --audience banking-api --issuer pqdoctor-gateway-01

It refuses requests without a valid assertion and hands the app those same x-pq-* headers. The app gets only those, never ones the request brought.

Node.js 24.7+ (node:crypto ML-DSA, no dependencies), from integrations/identity-bridge/node/pqdoctor-identity.mjs:

import { createVerifier, middleware } from "./pqdoctor-identity.mjs";
const verify = createVerifier({ jwksFile: "/etc/pqdoctor/jwks.json", audience: "banking-api", issuers: ["pqdoctor-gateway-01"] });
app.use(middleware(verify)); // req.pqIdentity.sub, .claims, .clientAuthPostQuantum — or 401

Scripts: pqdoctor identity-bridge verify --jwks F --audience A TOKEN prints the claims (exit 1 when refused). sign DIR --sub S --audience A makes a test assertion, to try a verifier without a client certificate. inspect TOKEN decodes one without checking it.

Mode How What the backend changes
Certificate forwarding RFC 9440 Client-Cert / Client-Cert-Chain, X-Client-*, optionally HMAC-signed Trusts the proxy’s headers; only the proxy can reach it
Signed assertion [listener.identity]: an ML-DSA JWT per request, or per connection in PROXY v2 Runs a verifier (above)
Delegated mTLS [listener.mint]: the proxy connects with a short-lived certificate for the client, from a mint CA Trusts the mint CA

A delegated certificate is marked as one:

  • it’s issued by the mint CA, never the client’s own CA;
  • its organization is pqdoctor delegated identity;
  • it carries the non-critical extension 2.25.162478307707916038624195251914586151539 (a UUID OID): the gateway, the original certificate’s SHA-256, and the original key’s algorithm.

It copies the client’s email, URI, DNS and IP SANs and its CN.

The limit: with delegated mTLS the backend authenticates pqdoctor’s delegation, not possession of Alice’s key. A bridge can’t recreate the client’s own TLS proof on a separate connection: that signature covers the client’s own handshake. If the backend must see that proof, use pqdoctor proxy wrap. It keeps the client’s mTLS end to end inside a post-quantum tunnel.

$ pqdoctor identity-bridge analyze proxy.toml
[own-key] tcp → tls://10.0.0.9:5432
bridge: wrap ✗
· the backend asks for a client certificate (required), from: Corp Users CA
· it trusts the same CA as the clients: it verifies the client's own private key, which a
terminating proxy can't reproduce (the client's signature covers its own TLS session)
→ keep that guarantee: `pqdoctor proxy wrap` — the client's mTLS stays end to end inside a
post-quantum tunnel
→ or accept delegation: make the backend trust a mint CA, set [listener.mint], and it sees
delegated certificates instead
what holds:
key exchange, client ⇄ proxy: post-quantum (X25519MLKEM768) for clients that offer it
client authentication: classical (ec-p256): an ML-DSA bridge signature doesn't change that
proxy ⇄ backend: TLS, X25519MLKEM768 (post-quantum), backend key ec-p256

For each tls:// backend it connects without a client certificate and records the TLS 1.3 CertificateRequest. That covers whether a certificate is asked for, whether it’s required, the CA names it accepts, and the signature schemes. It compares those with the listener’s client CA and mint CA, then picks:

  • assertion,
  • rfc9440,
  • delegated-mtls,
  • or wrap, when only the client’s own key will do.

It also flags a proxy ⇄ backend hop that isn’t protected, a backend reachable around the proxy, and a missing CRL, and states what holds for each part. It exits 1 if a listener can’t be bridged safely. --json for scripts; --no-probe reads the config only. pqdoctor proxy check prints the short version.

Terminal window
pqdoctor identity-bridge rotate /etc/pqdoctor/bridge # new signing.key; the old public key stays in jwks.json
# ship jwks.json to the backends (verifiers re-read it when it changes), then:
pqdoctor proxy reload
# once old assertions have expired (ttl, at most 300 s):
pqdoctor identity-bridge prune /etc/pqdoctor/bridge --kid <old kid>

signing.key is PKCS#8 (mode 0600). The key can’t be pruned while it’s the one signing. Revoke client certificates with pqdoctor proxy ca revoke DIR --cert F. That writes DIR/crl.pem, valid 7 days; re-sign it with pqdoctor proxy ca crl DIR from a timer. client_auth.crl takes any CA’s CRLs (PEM or DER) and reloads with the config. revocation = "allow-unknown" lets through certificates whose CA has no CRL loaded. crl_end_entity_only = true checks only the client’s own certificate.

  • Through a real proxy (proxy_e2e_identity, on Windows and the Ubuntu 26.04.1 VM):
    • Alice’s ECDSA certificate gives an assertion the backend verifies, with client_auth_pq: false and kex: X25519MLKEM768.
    • Bob’s ML-DSA-44 certificate gives client_auth_pq: true.
    • A client’s own pq-identity headers are replaced.
    • Someone outside the allow list, and Alice on /admin, get 403.
    • Carol’s revoked certificate is refused, and the same listener without the CRL lets her in.
    • The PROXY v2 assertion verifies for its own audience and not another’s.
    • authz refuses another method, a replay, and no assertion.
    • guard passes only the verified subject; going around the gateway gets 401.
    • The metrics count every outcome.
  • The analyzer picks wrap for a backend that trusts the clients’ CA, delegated-mtls for one that trusts the mint CA, and assertion for a loopback HTTP backend.
  • Interop with Node.js, 18/18 on Windows (Node 24.14.1, OpenSSL 3.5.5) and on the Ubuntu 26.04.1 VM (Node 24.22.3, OpenSSL 3.5.9):
    • Node verifies pqdoctor’s ML-DSA-44, -65 and -87 assertions, and refuses replay, another method and a changed sub.
    • pqdoctor verifies Node-signed ML-DSA-65 and refuses a tampered signature.
    • The full chain works: a Node HTTPS client with a certificate, through pqdoctor proxy, to a Node app with the middleware. It runs over X25519MLKEM768 and the app refuses requests that go around the gateway.
  • Cost per request (release builds, 13th Gen Core i7-13700HX):
Issue Verify Assertion
ML-DSA-44 0.25 ms 0.10 ms 3.9 KB
ML-DSA-65 0.39 ms 0.14 ms 5.1 KB
ML-DSA-87 0.44 ms 0.21 ms 6.9 KB

Windows figures; the Ubuntu lab VM (VirtualBox) measured 0.45 / 0.16 ms for ML-DSA-65. Not checked yet: nginx, Envoy and Traefik themselves (the configs follow their documented interfaces), and HSM-held bridge keys.