# Enable post-quantum TLS on Caddy

Source: https://pq-scan.com/fix/caddy-post-quantum-tls
Fixes: pq-kex-missing, pq-kex-supported-not-preferred. Server: Caddy. Effort: 5 min.
Requires: Caddy 2.10 or newer. Lab-tested on Caddy 2.11.9, Go 1.27.3, 2026-12-05 (PQ Scan Docker lab).

Caddy 2.10+ prefers the X25519MLKEM768 hybrid by default. Upgrade, and remove or fix any curves line that leaves it out.

## The fix

Run Caddy 2.10 or newer and **don't set `curves`**. Caddy then uses the Go defaults, which prefer X25519MLKEM768.

If you must keep a `curves` line, include the hybrid in it:

```caddy title="Caddyfile (site block)"
example.com {
	tls {
		curves x25519mlkem768 x25519 secp256r1 secp384r1
	}
}
```

Then reload: `caddy reload --config /etc/caddy/Caddyfile`.

The order of the list does not matter. Go ignores it and always prefers the hybrid when it is in the list. In the lab, `curves x25519 secp256r1 x25519mlkem768` gave the same result as the line above.

## Check your version first

```sh
caddy version
caddy build-info | grep "^go"
```

Caddy uses Go's TLS, not OpenSSL. The Go version it was built with decides what it can do.

| Official `caddy` Docker image | Built with | Post-quantum by default | `curves x25519mlkem768` |
|---|---|---|---|
| 2.11 (2.11.9) | Go 1.27.3 | Preferred | Accepted |
| 2.10 | Go 1.25.0 | Preferred | Accepted |
| 2.9 | Go 1.23.4 | No X25519MLKEM768 | Config error, Caddy won't start |
| 2.8, 2.7 | Go 1.22.3, 1.21.5 | No X25519MLKEM768 | Not tested |

Checked by running each image against the same probes on 2026-12-06. If you build Caddy yourself, use Go 1.24 or newer.

## What the common configs actually do

Tested in Docker (official `caddy:2` image, Caddy 2.11.9, Go 1.27.3) against five client offers, including the exact one browsers send. "Preferred" means the server asks for post-quantum even when the client led with a classical key share.

| Config | Post-quantum | What browsers get |
|---|---|---|
| No `curves` line (Go default) | Preferred | X25519MLKEM768 |
| `curves x25519mlkem768 x25519 …` (this fix) | Preferred | X25519MLKEM768 |
| `curves x25519 secp256r1 x25519mlkem768` (hybrid last) | Preferred | X25519MLKEM768 |
| `curves x25519 secp256r1 secp384r1` (old hardening guides) | Off | X25519 (classical) |

There is no "supported, not preferred" state on current Caddy: if the hybrid is allowed, it is preferred. The only way to lose it is a `curves` line that leaves it out.

## Verify

```sh
openssl s_client -connect example.com:443 -groups X25519MLKEM768 </dev/null 2>&1 | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
```

Or rescan with PQ Scan: the Confidentiality axis should read **PQ preferred**.

## Things that don't change
- Your certificate stays the same. Caddy's automatic certificates keep working as before (post-quantum certificates are not available for public websites yet).
- Clients without post-quantum support still connect with X25519 or P-256.
- If a CDN or load balancer terminates TLS in front of Caddy, visitors see the CDN's TLS, not this config. Fix it there too.

Verify after deploying: https://pq-scan.com/r/<your-domain>?fresh=1
