# Guide (Sample): OpenSSL 3.5+ & Reverse Proxy TLS 1.3 Hybrid Key Exchange

STATUS: PROTOTYPE SAMPLE GUIDE.

Standards referenced:
- **NIST FIPS 203** (ML-KEM-768 / ML-KEM-1024)
- **IETF RFC 10024** (`X25519MLKEM768` `0x11EC`, `SecP256r1MLKEM768` `0x11EB`, `SecP384r1MLKEM1024` `0x11ED`)

## 1. Confirm OpenSSL 3.5+ (or 4.0/4.1+)

OpenSSL 3.5 LTS, 3.6, 4.0, and 4.1 ship built-in FIPS 203 ML-KEM, FIPS 204
ML-DSA, and FIPS 205 SLH-DSA support without external providers. Check your
runtime first:

```sh
openssl version
openssl list -tls1_3 -tls-groups | grep -E 'X25519MLKEM768|SecP'
```
(Add `-all-tls-groups` if you also want to see alias names.)

## 2. Enable RFC 10024 hybrid groups in nginx (built against OpenSSL 3.5+/4.x)

Keep `TLSv1.2` alongside `TLSv1.3` (Intermediate profile, matching Mozilla /
TLSRef) unless you control every client and explicitly opt into `TLSv1.3`-only.
Disable static non-PFS RSA ciphers on TLS 1.2. Leaving `ssl_ecdh_curve` unset
enables `X25519MLKEM768` by default on OpenSSL 3.5/3.6 (and adds
`SecP256r1MLKEM768` by default on OpenSSL 4.0+, though not `SecP384r1MLKEM1024`).
If you configure groups explicitly, include all three RFC 10024 hybrids and put
`secp384r1` (P-384) ahead of 256-bit curves for classical fallback:

```nginx
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_ecdh_curve X25519MLKEM768:SecP384r1MLKEM1024:SecP256r1MLKEM768:secp384r1:X25519:prime256v1;
```

(On nginx builds that reject hybrid group names in `ssl_ecdh_curve`, pass them
via `ssl_conf_command Groups X25519MLKEM768:SecP384r1MLKEM1024:SecP256r1MLKEM768:secp384r1:X25519:prime256v1;`.)

Reload nginx and check that the configuration passes `nginx -t` with no unknown
group errors.

## 3. Verify both hybrid negotiation and classical fallback

Run **separate** probes so you prove both PQ negotiation and backward compatibility:

```sh
# 1) Confirm hybrid PQ negotiation (also test SecP384r1MLKEM1024 / SecP256r1MLKEM768 separately if needed)
openssl s_client -connect <host>:443 -servername <host> -tls1_3 -groups X25519MLKEM768 -brief </dev/null

# 2) Confirm classical TLS 1.3 fallback still connects for non-PQ clients
openssl s_client -connect <host>:443 -servername <host> -tls1_3 -groups X25519:prime256v1 -brief </dev/null

# 3) Confirm TLS 1.2 fallback negotiates ECDHE (skip if intentionally TLS 1.3-only)
openssl s_client -connect <host>:443 -servername <host> -tls1_2 -brief </dev/null

# 4) Confirm static non-PFS RSA key exchange is rejected on TLS 1.2 (must fail handshake)
openssl s_client -connect <host>:443 -servername <host> -tls1_2 -cipher kRSA -brief </dev/null
```

Confirm probe 1 prints `Negotiated TLS1.3 group: X25519MLKEM768`, probe 2
completes cleanly, probe 3 prints an `ECDHE-` ciphersuite, and probe 4 fails the
handshake. If probe 1 fails or times out while probe 2 succeeds, check for a
CDN, load balancer, or middlebox/firewall dropping ~1.5 KB multi-packet TLS
ClientHellos.
