# Enable post-quantum TLS on HAProxy

Source: https://pq-scan.com/fix/haproxy-post-quantum-tls
Fixes: pq-kex-missing, pq-kex-supported-not-preferred. Server: HAProxy. Effort: 5 min.
Requires: HAProxy built against OpenSSL 3.5 or newer. Lab-tested on HAProxy 3.4.9, OpenSSL 3.5.9, 2026-12-05 (PQ Scan Docker lab).

Make HAProxy prefer the X25519MLKEM768 hybrid key exchange, with classical fallback for old clients.

## The fix

Put the hybrid group in its own first tuple. The `/` tells OpenSSL to prefer it, even when a client first sends only a classical key share. HAProxy passes the string to OpenSSL as is, so the tuple syntax works.

```haproxy title="haproxy.cfg (global section)"
global
  ssl-default-bind-curves "X25519MLKEM768 / X25519:P-256:P-384"
```

Or per listener, on the `bind` line:

```haproxy title="haproxy.cfg (frontend)"
bind :443 ssl crt /etc/haproxy/certs/ curves "X25519MLKEM768 / X25519:P-256:P-384"
```

Keep the quotes: the string has spaces. Then check and reload: `haproxy -c -f /etc/haproxy/haproxy.cfg && systemctl reload haproxy`.

**Shortcut:** if your HAProxy uses OpenSSL 3.5+ and you have **no** `curves`, `ssl-default-bind-curves` or `ecdhe` setting, you already prefer post-quantum. The OpenSSL default does the same thing. Delete the old line instead of adding one.

## Check your OpenSSL first

```sh
haproxy -vv | grep "Running on"
# Running on SSL library version : OpenSSL 3.5.9 29 Sep 2026
```

You need OpenSSL 3.5 or newer. On older OpenSSL, `haproxy -c` stops with `unable to set SSL curves list`, so the check catches it before a reload.

| Where your HAProxy comes from | OpenSSL | Ready? |
|---|---|---|
| Official `haproxy` Docker images: 2.8, 3.0, 3.2, `lts` (3.4.9), `latest` (3.5.0), `lts-alpine` | 3.5.9 | Yes |
| Debian 12 (`haproxy` 2.6.12) | 3.0.x | No: `haproxy -c` rejects the line above |
| Other distro packages | the distro OpenSSL | Check with the command above |

Checked by running each image on 2026-12-06.

## What the common configs actually do

Tested in Docker (official `haproxy:lts` image, HAProxy 3.4.9, OpenSSL 3.5.9) 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 |
|---|---|---|
| `ssl-default-bind-curves "X25519MLKEM768 / X25519:…"` (this fix) | Preferred | X25519MLKEM768 |
| `curves "X25519MLKEM768 / X25519:…"` on `bind` (this fix) | Preferred | X25519MLKEM768 |
| No curves setting (OpenSSL 3.5 default) | Preferred | X25519MLKEM768 |
| `ssl-default-bind-curves X25519MLKEM768:X25519:…` (no `/`) | Supported, not preferred | X25519MLKEM768 |
| `ssl-default-bind-curves X25519:P-256:P-384` (old hardening guides) | Off | X25519 (classical) |
| `ecdhe prime256v1` on `bind` (old configs) | Off | P-256 only (classical) |

"Supported, not preferred" looks the same in a browser today, but a client that leads with a classical key share gets classical encryption. Preferring post-quantum closes that gap.

The old `ecdhe` option is the strictest trap: it limits TLS 1.3 to one classical curve. In the lab, clients that offered only X25519MLKEM768 and X25519 could not connect at all; a client offering P-256 got P-256.

## 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 (post-quantum certificates are not available for public websites yet).
- Clients without post-quantum support still connect with X25519 or P-256.
- This setting covers client-to-HAProxy connections. HAProxy-to-backend TLS uses `ssl-default-server-curves` (not tested here).
- If a CDN terminates TLS in front of HAProxy, 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
