# Migrate: TLS key exchange to hybrid

**What is at stake.** Someone who records encrypted traffic today could read it later if the classic key exchange (ECDHE, X25519, finite-field DH) is ever broken. That is "harvest now, decrypt later". The fix is to offer the hybrid group `X25519MLKEM768` (RFC 10024) first, with the classic groups after it.

**What it needs.** TLS 1.3. Post-quantum key exchange does not exist in TLS 1.2, so a client that only speaks 1.2 stays classic. Do not cap `MaxVersion` at 1.2 and do not remove 1.2 in the same step either.

**The usual fix is deletion.** Current stacks already offer the hybrid by default: OpenSSL 3.5.0+, Go 1.24+, JDK 27+, Node with OpenSSL 3.5. If the config pins a classic-only curve list, deleting the pin is often the whole change. If a pin is needed, put the hybrid first.

Lines marked "not run here" were not executed on the machine that wrote this file. Lines marked "tested here" were run with Node 24.11.1 (OpenSSL 3.5.4) on 2026-12-03.

## Side effect to tell the human

The hybrid client key share is 1,216 bytes instead of 32 for X25519 (1,184 for ML-KEM-768 plus 32), and the server share is 1,120 bytes (RFC 10024). The ClientHello can span two packets. A few old middleboxes and TLS servers mishandle that and drop or hang the connection. Test through the real network path, not only on localhost. If a server is affected, upgrading it is the fix; client-side opt-outs exist (Go: `GODEBUG=tlsmlkem=0`; Chrome: the `PostQuantumKeyAgreementEnabled` enterprise policy, which Google says will be removed) and are temporary.

## nginx

Requires: nginx linked to OpenSSL 3.5.0 or newer. Check: `nginx -V 2>&1 | grep -i openssl` (the "built with" and "running with" versions both matter).

Checked with `nginx -t` on nginx 1.30.8 for Windows linked to OpenSSL 3.5.9. Both variants below completed a local hybrid-only TLS 1.3 handshake.

```nginx
ssl_protocols TLSv1.2 TLSv1.3;
# either delete ssl_ecdh_curve entirely (OpenSSL 3.5 defaults already prefer the hybrid), or:
ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1;
```

Check the config: `nginx -t`. The human reloads (`nginx -s reload` or the service manager). Rollback: restore the previous `ssl_ecdh_curve` line, `nginx -t`, reload.

## Apache httpd

Requires: mod_ssl linked to OpenSSL 3.5.0+. Check: `httpd -V` or `apache2 -V`, and the `OpenSSL/` token in the server log at start.

Change (not run here):

```apache
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLOpenSSLConfCmd Groups X25519MLKEM768:X25519:prime256v1
```

Check: `apachectl configtest`. Rollback: remove or restore the `Groups` line.

## HAProxy

Requires: HAProxy built with OpenSSL 3.5.0+. Check: `haproxy -vv | grep -i openssl`.

Change (not run here):

```haproxy
global
    ssl-default-bind-curves X25519MLKEM768:X25519:P-256
```

Or delete a classic-only `ssl-default-bind-curves` / per-bind `curves` line. Check: `haproxy -c -f /etc/haproxy/haproxy.cfg`. Rollback: restore the line.

## Caddy

Caddy's docs list `x25519mlkem768` as a value for `curves` and say "It is recommended to not change the defaults." So: delete a `curves` line if one pins classic groups; if one must stay, put `x25519mlkem768` first. Which Caddy release turned the hybrid on by default: check the vendor docs (not verified here). Not run here.

## Go

Requires: Go 1.24+ (`go version`). Go 1.24 enables `X25519MLKEM768` by default when `Config.CurvePreferences` is nil; Go 1.26 also enables `SecP256r1MLKEM768` and `SecP384r1MLKEM1024` by default.

The explicit configuration below compiled on Go 1.27.4. Choose one of the two forms.

```go
// Preferred: delete CurvePreferences so the runtime default applies.
cfg := &tls.Config{MinVersion: tls.VersionTLS12}

```

If a list is required, use this alternative:

```go
cfg := &tls.Config{
    MinVersion:       tls.VersionTLS12,
    CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.X25519, tls.CurveP256},
}
```

Do not set `MaxVersion: tls.VersionTLS12`. Check for an environment override: `GODEBUG` containing `tlsmlkem=0` turns the default off. Rollback: restore the previous `CurvePreferences`.

## Node.js

Requires: `node -p process.versions.openssl` prints 3.5.0 or newer. Node 24.11.1 bundles OpenSSL 3.5.4. Distributions that link Node to the system OpenSSL may differ: check the printed value, not the Node version.

Change (tested here):

```js
// before
tls.createServer({ key, cert, ecdhCurve: 'X25519:P-256' });

// after: either delete ecdhCurve (default 'auto' uses OpenSSL's defaults) ...
tls.createServer({ key, cert });
// ... or put the hybrid first
tls.createServer({ key, cert, ecdhCurve: 'X25519MLKEM768:X25519:P-256' });
```

Results tested here (Node 24.11.1, local server on 127.0.0.1): with either "after" config, a default client, a hybrid-only client (`ecdhCurve: 'X25519MLKEM768'`) and a classic-only client (`ecdhCurve: 'X25519'`) all connected over TLS 1.3. With the "before" config, the hybrid-only client failed with `handshake_failure`. Note: `getEphemeralKeyInfo()` returns `{}` for the hybrid, so "a hybrid-only client connected" is the proof, not that call.

Local proof script (tested here, with your test CA in place of the placeholder path):

```sh
node -e "const t=require('tls'),fs=require('fs');const c=t.connect({host:'127.0.0.1',port:8443,servername:'localhost',ca:fs.readFileSync('test-ca.pem'),ecdhCurve:'X25519MLKEM768'},()=>{console.log('hybrid ok',c.getProtocol());c.end()});c.on('error',e=>{console.log('FAIL',e.message);process.exit(1)})"
```

Rollback: restore the previous `ecdhCurve`.

## Java

Requires: JDK 27+ (`java -version`). JEP 527 puts `X25519MLKEM768` first in the default TLS 1.3 groups; no code change is needed. JDK 24 to 26 have the ML-KEM and ML-DSA APIs (JEP 496, 497) but not hybrid TLS.

Change (not run here; Java was not installed): remove a `jdk.tls.namedGroups` system property or `SSLParameters.setNamedGroups(...)` call that lists only classic groups, or put `X25519MLKEM768` first:

```sh
-Djdk.tls.namedGroups="X25519MLKEM768,x25519,secp256r1,secp384r1"
```

Rollback: restore the previous property. Bouncy Castle JSSE: check the vendor docs.

## Python

The `ssl` module uses whatever OpenSSL the interpreter links to: check `python -c "import ssl; print(ssl.OPENSSL_VERSION)"`. With OpenSSL 3.5+ the defaults offer the hybrid. Python 3.12 has no `SSLContext` method to set groups, so the fix is the interpreter or base image, not code. Tested here: Python 3.12.6 links OpenSSL 3.0.15, so it cannot offer the hybrid. Which official Python builds ship OpenSSL 3.5: check the vendor docs.

## .NET

TLS goes through the operating system (SChannel on Windows, OpenSSL on Linux, Apple's stack on macOS). .NET 10 has `MLKem` and `MLDsa` classes, but hybrid TLS depends on the OS. Check the OS and its TLS library; on Linux, `openssl version`. Not verified here per OS.

## Managed load balancers and CDNs

The edge decides the key exchange, not your server. Change the provider's setting; `probe` is the judge.

- AWS Elastic Load Balancing: policies with `PQ` in the name offer hybrid post-quantum key exchange, for example `ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09` (the console default for new HTTPS listeners) or `ELBSecurityPolicy-TLS13-1-2-PQ-2025-09`. The CLI, CloudFormation and CDK have a different default, so check listeners created that way. Source: AWS ELB docs, checked 2026-12-03.
- Other providers: check the vendor docs, then probe.

The human changes the policy (rule 5). Rollback: the previous policy name, written down before the change.

## Fallback: a hybrid-capable proxy in front

For an appliance that cannot be upgraded, a proxy can terminate hybrid TLS at its public listener. nginx and HAProxy need a suitable TLS library. Caddy uses Go’s TLS stack. Identify where the proxy decrypts traffic and assess the classic-only backend hop separately.

## How to prove

`prove.md` P1 (re-scan), P2 (`probe --confirm-handshake` shows `X25519MLKEM768`), P3 (tests pass, a classic client still connects).
