Skip to content

pqdoctor proxy

The four things that usually stop a migration, and what the proxy does about each:

Blocker What the proxy does
The app’s TLS library has no ML-KEM The app never sees the client’s TLS. The proxy speaks X25519MLKEM768 to clients and plain or classical TLS to the app.
The key lives in an HSM that can’t hold lattice keys Hybrid key exchange needs no new key. The proxy uses the certificate and key you already have; ML-KEM keys are made per connection and never stored.
The other side might not support PQ Hybrid first, classical fallback, chosen per connection. Old clients keep working; status shows what share is post-quantum.
Your CA can’t issue PQ certificates Not needed for the key exchange, which is the part “harvest now, decrypt later” breaks. For PQ authentication on internal names, proxy ca makes an ML-DSA CA and the proxy serves that certificate only to clients that will trust it.
Terminal window
pqdoctor proxy init proxy.toml --listen 0.0.0.0:443 --backend 127.0.0.1:8443 \
--cert /etc/ssl/example.pem --key /etc/ssl/example.key
pqdoctor proxy check proxy.toml
sudo pqdoctor proxy install proxy.toml

Move the existing server to the backend port first (check tells you if :443 is still taken). Then check it from outside with pqdoctor’s own probes:

Terminal window
pqdoctor proxy verify www.example.org
✓ www.example.org:443 — Post-quantum: negotiates X25519MLKEM768
mode Clients speak The backend gets
http HTTPS: HTTP/1.1, HTTP/2, WebSocket (Upgrade) HTTP, or tls:// with backend mTLS, plus headers (below)
tcp any protocol inside TLS (IMAPS, LDAPS, databases, gRPC) the bytes, optionally after a PROXY protocol v2 header
tunnel-server a tunnel-client, over post-quantum-only mTLS a TCP backend, or udp://
tunnel-client anything, in the clear, on this machine (TCP, or UDP with udp = true) carried to the tunnel-server
starttls SMTP (25, 587), IMAP (143), POP3 (110) with STARTTLS / STLS the mail server, upgraded with its own STARTTLS when it offers it
turn TURN over TLS (turns:), for WebRTC a UDP relay to the call’s other peer
relay connectors, dialing in over post-quantum-only mTLS nothing itself: an http or tcp listener in the same file sends clients to them with backend = "relay://NAME"
connector nothing: it has no listening port, it dials the relay each client the relay hands it, connected to the app

A starter file for each: pqdoctor proxy init --mode tcp|tunnel-server|tunnel-client|starttls|turn|relay|connector (--protocol imap for IMAP). In http mode, [listener.http3] adds HTTP/3; any public listener can take [listener.acme].

Clients’ own copies of these headers are removed first, so they can’t be forged.

Header Value
X-Forwarded-For, X-Real-IP the client’s address (trust_forwarded = true appends instead, behind another proxy)
X-Forwarded-Proto, X-Forwarded-Host https, the Host asked for
X-PQ-Key-Exchange the group, e.g. X25519MLKEM768
X-PQ-Protected true when that group is post-quantum
X-TLS-Version TLSv1.3
X-Client-Verify SUCCESS or NONE
X-Client-Cert the client certificate, PEM, URL-encoded (nginx’s $ssl_client_escaped_cert)
X-Client-Cert-Subject-CN, X-Client-Cert-SHA256 its CN and fingerprint

Alt-Svc values for h3 are dropped from responses (strip_alt_svc_h3, on by default), so browsers stay on this post-quantum path instead of moving to a classical HTTP/3 port on the backend.

forward.proxy_protocol = true sends a v2 header before the first byte: the client’s address and port, PP2_TYPE_AUTHORITY (SNI), PP2_TYPE_ALPN, PP2_TYPE_SSL with the version, cipher and client-certificate CN, and two custom TLVs: 0xE0 the client’s leaf certificate (DER) and 0xE1 the key-exchange group name.

[listener.http3] # in an http listener: same port, over UDP
alt_svc_max_age = 86400

The proxy answers HTTP/3 over QUIC on the listener’s port and advertises it with Alt-Svc: h3=":443" on every HTTPS response (the backend’s own h3 entries are dropped). The QUIC side offers post-quantum groups only, X25519MLKEM768 by default. A client that can’t do one fails the QUIC handshake and falls back to HTTP/2 over TCP, which keeps the classical fallback; browsers do this on their own. Offering only post-quantum groups on QUIC is also what keeps X-PQ-Key-Exchange exact there, because the QUIC library doesn’t report which group a connection used. Request bodies over HTTP/3 are buffered up to max_body (32 MiB); responses stream.

Checked with pqdoctor’s own QUIC probe: pqdoctor quic <host> says “Post-quantum over QUIC: negotiates X25519MLKEM768”.

[[listener]]
name = "smtp"
listen = "0.0.0.0:25"
mode = "starttls"
protocol = "smtp" # smtp | imap | pop3
backend = "127.0.0.1:2525" # the mail server, moved to a local port
# require_starttls = false # true: no MAIL/AUTH, LOGIN, USER/PASS before STARTTLS
[listener.tls]
cert = "/etc/ssl/mx.pem"
key = "/etc/ssl/mx.key"
[listener.backend_tls] # the mail server's own STARTTLS, when it offers it
insecure_skip_verify = true # it's on this machine; or ca = "..."

The proxy relays the cleartext part of the dialog (greeting, EHLO / CAPABILITY / CAPA), makes sure STARTTLS (STLS) is offered exactly once, and answers the client’s STARTTLS itself with a post-quantum handshake. When the mail server offers STARTTLS too, the proxy upgrades that leg as well, so the server still sees a TLS session (Postfix’s smtpd_tls_auth_only, Dovecot’s disable_plaintext_auth). Bytes a client pipelines after STARTTLS are refused: that’s the STARTTLS command-injection class of bugs. A client that never says STARTTLS gets a plain session unless require_starttls is set. Leave it off on port 25, or servers that can’t do TLS can’t deliver to you.

forward.proxy_protocol = true sends a PROXY v2 header first, for Postfix’s smtpd_upstream_proxy_protocol = haproxy and Dovecot’s haproxy_trusted_networks.

Checked against Postfix 3.8 and Dovecot 2.3:

  • Postfix logged the proxy’s own STARTTLS to it (“TLS connection established … TLSv1.3”).
  • Dovecot answered CAPABILITY and CAPA over the upgraded session.
  • pqdoctor’s STARTTLS probe rated SMTP, IMAP and POP3 through the proxy post-quantum, and the servers themselves not post-quantum.

A browser’s DTLS is end to end between the two peers and pinned by fingerprints in the SDP, so nothing in the middle can terminate it. A relay can still change what the network sees. With iceTransportPolicy: "relay" and a turns: server, every packet of the call, the DTLS handshake included, travels inside the TLS connection to the relay. That connection is post-quantum when the client’s TLS offers X25519MLKEM768.

[[listener]]
name = "turn"
listen = "0.0.0.0:5349"
mode = "turn"
[listener.tls]
cert = "/etc/ssl/turn.pem"
key = "/etc/ssl/turn.key"
[listener.turn]
realm = "example.com"
relay_ip = "203.0.113.10" # where peers reach this machine
secret_file = "turn-secret.txt" # time-limited credentials, or:
# users = [{ name = "alice", password = "a-long-password" }]
# allow_peers = ["10.0.0.0/8"] # private and loopback peers are refused unless listed
new RTCPeerConnection({
iceServers: [{ urls: "turns:turn.example.com:5349", username, credential }],
iceTransportPolicy: "relay",
});

What’s there:

  • Binding, Allocate (UDP relay, EVEN-PORT and reservations), Refresh, CreatePermission, ChannelBind, Send and Data indications, ChannelData.
  • Long-term credentials, or the time-limited ones coturn’s use-auth-secret uses: username <expiry>:<id>, password the base64 HMAC-SHA1 of it with the secret.
  • Signed nonces, MESSAGE-INTEGRITY and FINGERPRINT.
  • Peers on loopback, private, CGNAT, link-local, multicast and unspecified addresses are refused unless allow_peers lists them, so the relay can’t be used to reach into your network.

Checked with coturn’s turnutils_uclient over TLS through the relay to an echo peer: channels and send indications both relayed 120 of 120 messages, 0 lost.

Whether a given browser’s TURN-over-TLS offers ML-KEM is up to that browser’s WebRTC stack. pqdoctor_proxy_handshakes_total{listener="turn",group=...} shows what each client actually negotiated.

[listener.acme]
domains = ["www.example.com", "example.com"]
email = "ops@example.com"
agree_tos = true # you accept the CA's terms (Let's Encrypt: letsencrypt.org/repository)
# challenge = "tls-alpn-01" # default: answered on this listener's port (the CA connects to 443)
# challenge = "http-01" # or: answered on http_listen, which also redirects to https
# http_listen = "0.0.0.0:80"
# directory = "https://acme-v02.api.letsencrypt.org/directory"

The proxy gets the certificate itself:

  • It writes it to tls.cert / tls.key atomically, hot-reloads it, and renews when fewer than renew_days (30) are left.
  • Until the first certificate arrives it serves a short-lived placeholder, so the listener can start.
  • tls-alpn-01 needs nothing else listening. The CA’s validation connection asks for ALPN acme-tls/1 and gets the challenge certificate; everyone else gets the real one.
  • Failures retry with backoff (5 minutes up to 6 hours) and count in pqdoctor_proxy_acme_failures_total.
  • The proxy’s own connection to the CA is post-quantum when the CA offers it.

Checked against Pebble, Let’s Encrypt’s ACME test server: tls-alpn-01 for two names and http-01 for a third were validated, issued, served and verified, and a restart with current certificates placed no new order. Wildcards need dns-01 (your DNS provider’s API), which isn’t supported.

pq_policy = "allow" # the listener's default: allow | warn | require
[[listener.policy]]
sni = "admin.example.com" # post-quantum only, refused at the handshake
action = "require"
[[listener.policy]]
path_prefix = "/admin" # http: 403 for a classical connection
action = "require"
[[listener.policy]]
path_prefix = "/"
action = "require"
require_after = "2027-06-30" # warn until then, require after: a dated migration

A require name gets the listener’s post-quantum-only TLS config at the handshake (a classical client fails cleanly, counted as reason="policy: post-quantum required"). A require path answers 403 and says what to upgrade. warn serves the request and tells the backend (X-PQ-Policy: warn). Tunnels are require by construction.

Terminal window
pqdoctor proxy clients proxy.toml
[web] 18,233 connections, 3,102 classical
3 kind(s) of client make up all the classical traffic:
· Python (OpenSSL 1.1.1–3.4) — 2,410 classical (78% of it)
why: OpenSSL got ML-KEM in 3.5.0 (2025-04); 1.1.1–3.4 can't offer it
fix: OpenSSL 3.5+ (Debian 13, Ubuntu 25.10/26.04, RHEL 9.7+/10.1+), …
seen as: python-requests/2.31.0

pqdoctor’s diagnosis, turned around: the proxy records every ClientHello, fingerprints it (JA4, plus a hash of the offered groups, because JA4 leaves groups out and the groups are what separate an OpenSSL 3.0 client from a 3.5 one), names the TLS stack, and says what upgrade makes it post-quantum: OpenSSL 1.1.1–3.4, Go before 1.24, the pre-standard Kyber draft (Chrome 124–130, Go 1.23), Java before JDK 25.0.5 (or 27), Schannel or rustls without aws-lc, NSS before 132, TLS 1.2-only stacks. In http mode the User-Agent refines it. GET /clients on the admin port gives the JSON. A client refused by a require policy is recorded too; it’s the one worth diagnosing.

pqdoctor_proxy_handshake_kinds_total{kind="full"|"resumed"|"hrr"} and pqdoctor_proxy_resumed_pq_total. rustls resumes with psk_dhe_ke, so a resumed session still runs a fresh key exchange, and the proxy counts it by the group that exchange used. Checked: a resumed connection is HandshakeKind::Resumed with X25519MLKEM768. A HelloRetryRequest costs a round trip. The client doctor tells you which clients cause them (they offer ML-KEM but send no key share for it).

Keys in an HSM, the Windows store, or another machine

Section titled “Keys in an HSM, the Windows store, or another machine”
[listener.tls]
cert = "/etc/ssl/www.pem"
# key = "/etc/ssl/www.key" # a file, or one of:
key_source = "pkcs11:token=web;object=tls?module-path=/usr/lib/softhsm/libsofthsm2.so&pin-source=file:/etc/pqdoctor/pin"
# key_source = "cng:3f2a…(SHA-1 thumbprint)" # Windows certificate store
# key_source = "keyless:signer.internal:9443/web" # a keyless signer (below)

The HSM only does what it already does, RSA or ECDSA signing. ML-KEM is ephemeral and stays in software, so nothing new goes into the HSM. PKCS#11 takes RFC 7512 URIs (Thales, Entrust, Utimaco, YubiHSM, SoftHSM), and pin-source=file: keeps the PIN out of the config.

Keyless, for when the HSM is in another box: run mode = "keyless" next to it, and the proxy sends it the handshake to sign over post-quantum mTLS. Client certificates are required, or the listener refuses to start. Cloudflare’s Keyless SSL is the same architecture.

[[listener]]
name = "signer"
listen = "0.0.0.0:9443"
mode = "keyless"
[listener.tls]
cert = "signer.pem"
key = "signer.key"
[listener.client_auth]
mode = "require"
ca = "proxies-ca.pem"
[listener.keyless]
keys = [{ id = "web", key_source = "pkcs11:token=web;object=tls?module-path=…" }]

Checked with SoftHSM 2.6.1: ECDSA P-256 and RSA-2048 (RSA-PSS) keys in the token, directly and behind a keyless signer.

For identity a backend can verify on its own, use the identity bridge: an ML-DSA-signed, audience-bound, short-lived assertion of the verified client, with verifiers for nginx, Envoy, Traefik and Node, and an analyzer that says when only wrap will do. On top of the X-Client-* headers, the proxy sends:

  • RFC 9440 Client-Cert / Client-Cert-Chain (forward.rfc9440, on by default).
  • A signature over the identity headers. Set forward.sign_secret_file and the proxy adds X-PQ-Signature: v1; t=<unix>; sig=<base64url HMAC-SHA256>. The signed text is pqdoctor-proxy-v1\n<t>\n<method>\n<host>\n<path>\n<x-pq-key-exchange>\n<x-client-verify>\n<x-client-cert-sha256>\n<x-forwarded-for>, so the backend can tell the headers came from the proxy.
  • Identity re-minting, for backends that only accept real TLS client certificates (tcp, tunnel-server with a tls:// backend). The proxy verifies the client, then connects with a fresh, short-lived certificate for the same subject and SANs, from a CA the backend trusts:
[listener.mint]
ca_cert = "mint-ca.pem"
ca_key = "mint-ca.key"
minutes = 60

pqdoctor proxy check prints every hop and fails if a classical or plaintext segment crosses a network:

path:
client ⇄ proxy: TLS, X25519MLKEM768 first, classical for old clients
proxy ⇄ backend: plain on loopback 127.0.0.1:8080 (never on a network) ✓
no classical or plaintext segment on a network ✓
  • Same host: a loopback or Unix-socket backend (backend = "unix:/run/app.sock").
  • Backend elsewhere: a tunnel-server next to it, or tls:// with backend_tls.ca and/or pin_sha256 (base64 SHA-256 of the backend’s SubjectPublicKeyInfo).
  • Bypasses: it also checks whether a loopback backend answers on this host’s own addresses (a way around the proxy). With --online it runs pqdoctor’s QUIC probe on each public name and reads its HTTPS DNS record, to find an HTTP/3 path around the proxy. forward.alt_svc_clear = true sends Alt-Svc: clear so browsers forget old h3 endpoints.

Tunnels: hybrid authentication, QUIC datagrams, wrap

Section titled “Tunnels: hybrid authentication, QUIC datagrams, wrap”
  • hybrid_auth: each end also signs the session’s TLS exporter with a pinned Ed25519 key, so authentication needs both the ML-DSA certificate and the Ed25519 key. pqdoctor proxy ca ed25519 FILE makes one and prints its public key.
  • transport = "quic" for UDP tunnels: UDP flows travel as QUIC datagrams (RFC 9221), with no head-of-line blocking. Keep tunnelled MTUs at 1280 (WireGuard).
  • pqdoctor proxy wrap DIR --tunnel host:9443 --target 10.0.0.5:443 [--udp]: for traffic you can’t terminate. It writes both agents’ configs, an ML-DSA CA, certificates and pinned Ed25519 keys. The inner TLS, mTLS and pinning stay end to end; between the agents everything is inside post-quantum TLS. It needs an agent on the client side, so it fits managed clients and site-to-site links, not the public internet.
  • VPNs: pqdoctor fix --stack strongswan adds ke1_mlkem768 (RFC 9370, strongSwan 6) to IKE and ESP proposals; --stack wireguard explains Rosenpass.
  • pqdoctor proxy install proxy.toml --socket-activation (Linux): systemd owns the listening sockets, so a restart never refuses a connection.
  • Or reuse_port = true plus net.ipv4.tcp_migrate_req = 1 (Linux 5.14+), for a binary swap: 10 restarts under load, 247 requests, 0 failed. Without the sysctl, the kernel resets connections queued on the old listener (2 of 277); proxy check says so.
[listener.client_auth]
mode = "require" # or "optional"
ca = "clients-ca.pem" # classical or ML-DSA CAs
crl = ["clients-crl.pem"] # revocation (PEM or DER); `pqdoctor proxy ca revoke DIR --cert F`

The proxy verifies client certificates itself; a terminating proxy can’t pass the original handshake through (the client’s signature covers the TLS transcript). The backend gets the verified identity instead, as headers (http) or PROXY v2 TLVs (tcp). For a backend that wants mTLS from the proxy, give [listener.backend_tls] a cert and key.

For protocols that aren’t TLS, put a pqdoctor at each end. Between them: TLS 1.3, post-quantum groups only, client certificates required.

ssh -p 2222 localhost ─▶ tunnel-client :2222 ══ X25519MLKEM768, mTLS ══▶ tunnel-server :8443 ─▶ sshd :22
WireGuard ─▶ tunnel-client udp :51820 ══ … ══▶ tunnel-server ─▶ udp://10.0.0.5:51820
Terminal window
pqdoctor proxy ca init tunnel-ca
pqdoctor proxy ca issue tunnel-ca --host tunnel.example.org # the server's certificate
pqdoctor proxy ca issue tunnel-ca --client --cn laptop-7 # one per client
pqdoctor proxy init server.toml --mode tunnel-server --listen 0.0.0.0:8443 --backend 127.0.0.1:22
pqdoctor proxy init client.toml --mode tunnel-client --listen 127.0.0.1:2222 --backend tunnel.example.org:8443

UDP flows are one TLS connection per local peer, datagrams framed as a 2-byte length and the payload. ALPN (pqdoctor-tunnel/1+tcp / +udp) makes a mismatched pair fail at the handshake with a clear error, not with garbage.

For SSH you may not need a tunnel: OpenSSH 9.9+ has mlkem768x25519-sha256 (pqdoctor ssh <host> checks, pqdoctor fix --stack sshd sets it).

For an app whose machine can’t, or shouldn’t, take connections from the internet (behind NAT, a home or office network, a locked-down VM), put a connector next to it and a relay on a public machine. The connector dials out; the app’s machine opens no port.

browser ══ X25519MLKEM768 ══▶ relay host [web] http, backend = "relay://connectors/blog"
│ takes a parked connection
[connectors] relay ◀══ PQ-only mTLS, dialed out ══ connector ─▶ 127.0.0.1:3000
Terminal window
pqdoctor proxy shield shield/ --relay relay.example.org:7443 --app 127.0.0.1:3000 --name blog --public blog.example.org

Add --test-cert to try it before you have a certificate for the public name (a private test CA; browsers won’t trust it). Flarebox’s Shield page does the same from a form, and runs either end inside the app.

That writes both ends: an ML-DSA-65 CA, the relay’s certificate, a client certificate for the connector (its CN, blog, routes it), relay/relay.toml and connector/connector.toml. Give the relay your certificate for the public name (or uncomment its [listener.acme]), then pqdoctor proxy install each file on its machine.

How it works:

  • The connector keeps pool connections (default 4) parked at the relay, each TLS 1.3 with post-quantum groups only and its client certificate. The relay refuses any connector whose certificate isn’t from client_auth.ca (it must be require).
  • When a client arrives, the relay hands it one parked connection. The connector connects to its backend and says so (or says the backend is down: the client gets 502 at once), then the connection carries that client’s bytes both ways. The connector opens a replacement straight away, so the pool is the burst it absorbs without waiting, not a cap.
  • The relay checks each parked connection every 20 s; either side drops a silent one. A connector that loses the relay reconnects with backoff (1 s doubling to 60 s, with jitter), so a relay restart heals on its own.
  • relay://NAME/CN sends clients only to the connector whose certificate has that CN, so several apps can share one relay port and never receive each other’s clients. relay://NAME takes any connector parked there.
  • The relay’s public side is an ordinary http or tcp listener, so it carries HTTP/1.1, HTTP/2, WebSocket, or raw TCP (with a PROXY v2 header if you set it).
  • UDP (WireGuard, DNS, game servers): give the connector a udp:// backend and send flows to it with relay+udp://NAME/CN. On the relay, a tunnel-client with udp = true takes plain UDP from anyone (the protocol’s own encryption covers that hop), and a tunnel-server takes UDP from pqdoctor tunnel-clients over post-quantum mTLS. Each flow is one hand-over, its datagrams framed as in tunnels. proxy shield --app udp://127.0.0.1:51820 writes it that way.
  • A plain public TCP port works the same way: a tunnel-client on the relay with backend = "relay://NAME/CN".
  • pqdoctor proxy status on the relay lists the connectors parked, by name. hybrid_auth works here too.

A connector’s file:

[[listener]]
name = "blog"
mode = "connector" # no listen: it doesn't take connections
backend = "127.0.0.1:3000" # tls://… and unix:/… work too
[listener.connector]
relay = "relay.example.org:7443"
# relays = ["relay2.example.org:7443"] # more relays: a full pool at each, at once
pool = 4
# require_mldsa = true # the default: refuse a relay with a classical certificate
[listener.connector.tls]
ca = "relay-ca.pem" # the CA that issued the relay's certificate
cert = "connector.pem" # its CN names this connector
key = "connector.key"

connector.relays lists more relays. The connector keeps a full pool parked at each one at the same time, so a visitor who reaches any of them is served, and losing a relay loses nothing already parked at the others. There’s no failover step to wait for. Put the relays behind DNS with several addresses, or give visitors one name per relay. Leave connector.tls.sni unset so each relay is checked against its own name. proxy status on the connector shows what’s parked where (parkedByRelay).

Tested across two machines (lab/relay/): with relay A stopped for 15 s, 276 of 276 requests through relay B succeeded, and A’s pool refilled when it came back.

Every connection to a relay is TLS 1.3 with post-quantum key exchange only: a client that offers only classical groups is refused at the handshake. After it, a connector is let in only if all of these hold, or it’s told it was refused and the relay’s log says why:

  • Its certificate is from client_auth.ca, valid, and for client authentication (client_auth.crl revokes one; pqdoctor proxy ca revoke).
  • Key and signature are ML-DSA (or SLH-DSA) (require_mldsa, on by default). A connector checks the relay’s certificate the same way (connector.require_mldsa).
  • It’s on the allow list, by CN and key pin, when the list isn’t empty. Without one, any certificate from the CA can park under the name it carries; proxy check warns.
  • Within the limits: connections parked by one connector and in all, and visitors waiting for one connector and in all. The per-connector caps keep one tenant’s burst from using up what the others need. Over a limit, the connector is refused, or the visitor gets an error at once instead of a queue.
[listener.relay]
require_mldsa = true # the default
max_parked_per_connector = 64 # defaults
max_parked = 1024
max_waiting_per_connector = 256 # visitors waiting for one connector…
max_waiting = 1024 # …and for all of them
allow = [
{ cn = "blog", pin_sha256 = ["Yq0…="] }, # pqdoctor proxy ca pin connector.pem
{ cn = "wiki", pin_sha256 = ["k3B…="] },
]

proxy shield writes the list with its own connector pinned. To add another app to the same relay, issue it a client certificate from the same CA (pqdoctor proxy ca issue ca --client --cn wiki), add a line with its pin, and pqdoctor proxy reload. Refusals are counted under connector refused in proxy status, and logged with back-off so a misbehaving connector can’t flood the log.

Hop Key exchange Authentication
visitor ⇄ relay X25519MLKEM768 when the visitor supports it, classical otherwise (counted) your usual certificate for the public name, usually classical
relay ⇄ connector post-quantum only ML-DSA both ways, plus the allow list
connector ⇄ app none: plain on loopback (or tls://, then the app’s own TLS) none

So a shield gives post-quantum confidentiality on the network hops, not post-quantum authentication from the browser to the app: browsers don’t do ML-DSA yet. proxy check prints this for each listener.

Compared with Cloudflare Tunnel (cloudflared), which does the same with Cloudflare’s edge as the relay: here you run the relay, the relay ⇄ connector hop is post-quantum only with ML-DSA certificates each way, and it carries any TCP protocol tcp mode can serve.

The proxy watches every certificate, key and CA file it uses (watch_interval, default 5 s). When a file changes and then stays the same for one more interval (certbot and cert-manager are done writing), it reloads:

  • every listener’s TLS config is built first; only if all of them build — certificates parse, keys match, CAs load — are they swapped in;
  • new handshakes use the new certificate; open connections keep theirs; nothing is unbound;
  • a key that doesn’t match its certificate is refused and the previous one keeps serving: status and the log say why, and pqdoctor_proxy_reloads_total{result="failed"} counts it;
  • session tickets survive the swap.

Reload by hand with pqdoctor proxy reload proxy.toml, systemctl reload, kill -HUP, or on Windows sc control pqdoctor-proxy-<name> paramchange.

Stop (SIGTERM, Ctrl-C, service stop): no new connections, /healthz answers 503 so load balancers move away, HTTP connections are asked to finish (GOAWAY / Connection: close), and everything gets drain_timeout seconds (default 30). Upgrading pqdoctor itself: with reuse_port = true (Linux, macOS) the new process binds next to the old one before it stops. Measured on Linux: 0 failed requests out of 60 during the swap.

Terminal window
pqdoctor proxy ca init pq-ca # ML-DSA-65 (--alg ml-dsa-44 | ml-dsa-87 | ecdsa-p256)
pqdoctor proxy ca issue pq-ca --host api.internal --host 10.0.0.5
[listener.tls]
cert = "/etc/ssl/example.pem" # your existing certificate, for everyone
key = "/etc/ssl/example.key"
pq_cert = "pq-ca/server.pem" # ML-DSA, for clients that trust pq-ca
pq_key = "pq-ca/server.key"
pq_sni = ["api.internal"]

Listing ML-DSA in signature_algorithms isn’t enough to get the ML-DSA certificate: rustls and OpenSSL 3.5 list it whatever CAs they trust, so serving it on that alone would break them. A client gets it only if it also asks for a pq_sni name, names the issuing CA in its certificate_authorities extension, or the listener sets pq_all = true (every client trusts the CA). Checked with Node 24 (OpenSSL 3.5.5): asking for localhost it got the ECDSA certificate, asking for api.internal the ML-DSA-65 one, both over X25519MLKEM768.

Trust Anchor IDs (experimental). A client can also say which root it trusts with the trust_anchors extension (draft-ietf-tls-trust-anchor-ids, code point 0xca34 until IANA assigns one). Name each chain’s root with pq_trust_anchor_id = "32473.1" and trust_anchor_id = "32473.2":

  • A client that lists the ML-DSA root gets the ML-DSA chain, if it can verify ML-DSA.
  • A client that lists only the classical root gets the classical chain.

Checked with a BoringSSL client; details on ML-DSA certificates.

Terminal window
pqdoctor proxy bench # a built-in loopback server: CPU and bytes alone
pqdoctor proxy bench --resume # resumed handshakes
pqdoctor proxy bench --cert-alg ml-dsa-65 # with an ML-DSA certificate
pqdoctor proxy bench www.example.org # a server you run (at most 1000 handshakes, 16 at a time)
pqdoctor proxy bench www.example.org --hold 10000 # open connections, to measure memory
pqdoctor proxy bench api.internal:443 --ca ca.pem --cert client.pem --key client.key # mTLS, e.g. an ML-DSA client certificate

Measured on the Ubuntu 26.04.1 lab VM (a VirtualBox guest on a 13th Gen Core i7-13700HX; method and raw CSV in the lab):

X25519 X25519MLKEM768
Proxy CPU per full handshake 5.42 ms 5.74 ms
Median full handshake, loopback 2.24 ms 2.60 ms
Bytes per handshake (both ways) 1,131 3,403
With an ML-DSA-65 certificate 9,496 11,768
Memory per open TLS connection 11.5 KiB (10,000 held)

On this VM system calls dominate the CPU figures (a guest on Hyper-V is about 10× faster with the same build); the difference is what ML-KEM costs: about 0.3 ms of server CPU and 2.3 KB per full handshake. An ML-DSA-65 certificate adds about 8.4 KB. Over a real network the bytes matter more than the CPU. pqdoctor proxy bench measures your own machine.

The admin port (127.0.0.1:9477 by default; admin.listen = "off" turns it off) answers GET /healthz, GET /status (JSON), GET /metrics (Prometheus) and POST /reload. A non-loopback admin address needs admin.token_file (a bearer token for /reload).

Besides connections and handshakes, each listener in /status reports:

  • refusedLimit: connections refused at max_connections.
  • chainsServed: ML-DSA chains vs classical, and how many a trust anchor ID decided.
  • backendGroups: the key exchange of the proxy’s own backend connections.
  • quicClientInitial: what HTTP/3 clients sent before the server’s first flight.

pqdoctor assure collect reads these.

Terminal window
pqdoctor proxy status proxy.toml
[main] http 127.0.0.1:18443 → 127.0.0.1:18080
16 connections (0 open), 57.1% post-quantum: 4 PQ / 3 classical
handshake failures: closed during handshake 8, no shared signature scheme 1
certificate: 396 days left; ML-DSA certificate: 396 days left
Metric
pqdoctor_proxy_handshakes_total{group, pq} by key-exchange group
pqdoctor_proxy_pq_share share of post-quantum handshakes
pqdoctor_proxy_handshake_failures_total{reason} no shared key-exchange group, no client certificate, bad certificate, timeout, …
pqdoctor_proxy_handshake_seconds histogram, accept to handshake done
pqdoctor_proxy_certificate_not_after_seconds alert before it passes
pqdoctor_proxy_connections_active, _bytes_received_total, _backend_failures_total, _reloads_total{result}
pqdoctor_proxy_starttls_cleartext_total, _acme_certificates_total, _acme_failures_total, _turn_allocations_total
pqdoctor_proxy_handshake_kinds_total{kind}, _resumed_pq_total, _policy_refused_total, _policy_warned_total
OS pqdoctor proxy install proxy.toml makes
Linux /etc/systemd/system/pqdoctor-proxy-<name>.service: restart on failure, reload = SIGHUP, stop = drain, sandboxed (read-only filesystem, no new privileges, only CAP_NET_BIND_SERVICE; systemd-analyze security rates it 2.3, OK). --user to run as a user instead of root.
macOS a LaunchDaemon, /Library/LaunchDaemons/com.pqdoctor.proxy.<name>.plist
Windows a Windows service pqdoctor-proxy-<name>: automatic (delayed) start, restart on failure, Stop drains, ParamChange reloads; log in %ProgramData%\pqdoctor\proxy-<name>.log. Run from an Administrator terminal.

--dry-run prints what it would do; pqdoctor proxy uninstall --name <name> removes it.

drain_timeout = 30 # seconds open connections get on stop
watch_interval = 5 # seconds between certificate-file checks (0: only on reload)
[admin]
listen = "127.0.0.1:9477" # or "off"
# token_file = "admin.token"
[[listener]]
name = "web"
listen = "0.0.0.0:443"
mode = "http" # http | tcp | tunnel-server | tunnel-client
backend = "127.0.0.1:8080" # tls://host:port, udp://host:port (tunnel-server)
reuse_port = false
max_connections = 0 # 0: no limit
idle_timeout = 300
handshake_timeout = 10
connect_timeout = 5
[listener.tls]
cert = "cert.pem"
key = "key.pem"
# pq_cert, pq_key, pq_sni, pq_all, pq_trust_anchor_id, trust_anchor_id — the ML-DSA certificate (above)
# groups = ["X25519MLKEM768", "SECP256R1MLKEM768", "X25519", "SECP256R1", "SECP384R1"]
# require_pq = false # true: post-quantum only (TLS 1.3); the default for tunnels
# min_version = "1.2"
# alpn = ["h2", "http/1.1"]
# [listener.client_auth]
# mode = "require" # off | optional | require
# ca = "clients-ca.pem"
# [listener.backend_tls] # tls:// backends, and a tunnel-client's tunnel-server
# ca = "backend-ca.pem" # default: Mozilla's roots
# sni = "app.internal"
# cert = "proxy-client.pem" # backend mTLS
# key = "proxy-client.key"
[listener.forward]
headers = true
trust_forwarded = false
proxy_protocol = false # tcp, tunnel-server, starttls
strip_alt_svc_h3 = true
# [listener.http3] # http: HTTP/3 over QUIC, post-quantum only
# groups = ["X25519MLKEM768"]
# alt_svc_max_age = 86400
# max_body = 33554432
# [listener.acme] # get and renew the certificate
# domains = ["www.example.com"]
# agree_tos = true
# protocol = "smtp" # starttls: smtp | imap | pop3
# require_starttls = false
# backend_starttls = true
# [listener.turn] # turn
# realm = "example.com"
# relay_ip = "203.0.113.10"
# secret_file = "turn-secret.txt"
# relay_min_port = 49152
# relay_max_port = 65535
# allow_peers = []
# max_lifetime = 3600

Relative paths are relative to the file. Unknown keys are refused, so a typo can’t silently do nothing; pqdoctor proxy check names every problem with its listener.

  • Terminate a browser’s DTLS. WebRTC’s DTLS is end to end by design; the TURN relay wraps it in post-quantum TLS instead.
  • Make a classical-only public client post-quantum. It’s measured (telemetry), named (client doctor), gated (require, require_after), or routed around (wrap) where you control the client.
  • Prove there’s no bypass in a network it can’t see. proxy check lists what it checked, from the host and online.
  • ML-DSA for arbitrary public clients, and that’s fine for now: an authentication downgrade needs a quantum computer during the handshake. Harvest-now-decrypt-later needs only ML-KEM, which every listener has.
  • Wildcards (ACME dns-01), MASQUE CONNECT-UDP, zero-refusal restarts on Windows, 0-RTT (off: it can be replayed).