# How to Prepare for the Post-Quantum Cryptography Transition: ML-KEM, ML-DSA and TLS Setup

> AI Release · @ai_releaseorg · https://ai-release.org/guides/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr_en.html

## AI summary

Time to complete: 60 minutes Difficulty: Intermediate

### Key facts

1. Time to complete: 60 minutes (source: #tldr; status: заявление источника)
2. Difficulty: Intermediate (source: #tldr; status: заявление источника)
3. You will need: OpenSSL 3.5 or newer with ML-KEM/ML-DSA support (verify with openssl version), nginx with ssl_ecdh_curve support, curl, a Linux test host with root access, and a staging domain you can restart (<your-domain>) (source: #tldr; status: заявление источника)
4. Linux or macOS host (Windows works through WSL2); bash as your shell. (source: #requirements; status: заявление источника)
5. OpenSSL 3.5+ on PATH. Older builds do not expose ML-KEM or ML-DSA; check the documentation for your distribution's package name if openssl version reports something older. (source: #requirements; status: заявление источника)
6. nginx on the staging host, and permission to edit nginx.conf and restart the service. (source: #requirements; status: заявление источника)

### Direct answers

**What is required?** — Linux or macOS host (Windows works through WSL2); bash as your shell.; OpenSSL 3.5+ on PATH. Older builds do not expose ML-KEM or ML-DSA; check the documentation for your distribution's package name if openssl version reports something older.; nginx on the staging host, and permission to edit nginx.conf and restart… (#requirements)
**How to do it?** — Step 1. Check what your OpenSSL build can actually do → Step 2. Turn on hybrid key exchange and generate ML-DSA keys → Step 3. Verify negotiation on the real endpoint (#step-1)
**Which topics does it cover?** — постквантовая криптография, переход на постквантовую криптографию, ML-KEM, X25519MLKEM768 настройка, как включить PQC в OpenSSL (#entities)
**What are the key points?** — Time to complete: 60 minutes Difficulty: Intermediate (#tldr)

- Canonical: https://ai-release.org/guides/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr_en.html
- Markdown: https://ai-release.org/guides/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr_en.md
- JSON: https://ai-release.org/guides/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr_en.json

## TL;DR

- **Time to complete:** 60 minutes
- **Difficulty:** Intermediate
- **You will need:** OpenSSL 3.5 or newer with ML-KEM/ML-DSA support (verify with `openssl version`), nginx with `ssl_ecdh_curve` support, `curl`, a Linux test host with root access, and a staging domain you can restart (`<your-domain>`)

## What you will get

- A local TLS 1.3 test server on port `4433` that negotiates the hybrid post-quantum group `X25519MLKEM768` — confirmed by a client-side `Server Temp Key` line.
- An ML-DSA keypair on disk (`mldsa65.key` / `mldsa65.pub`) plus a signature file produced and verified locally.
- A drop-in `nginx.conf` snippet and a filled-in crypto inventory checklist that lists every RSA/ECDSA endpoint you must migrate.

## Quick start

```bash
openssl version
openssl list -kem-algorithms | grep -i "ML-KEM"
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -noenc -keyout test.key -out test.crt -days 2 -subj "/CN=localhost"
openssl s_server -accept 4433 -cert test.crt -key test.key -groups X25519MLKEM768 -tls1_3
```

Details and verification — in the steps below.

## Requirements and setup
![Illustration: Requirements and setup](https://ai-release.org/guides/img/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr-en-1.jpg?v=1796395310)


- Linux or macOS host (Windows works through WSL2); `bash` as your shell.
- OpenSSL 3.5+ on `PATH`. Older builds do not expose ML-KEM or ML-DSA; check the documentation for your distribution's package name if `openssl version` reports something older.
- nginx on the staging host, and permission to edit `nginx.conf` and restart the service.
- Two free terminals: one runs the server, one runs the client.
- A short-lived test certificate only for the lab. Do not move the self-signed cert from this guide into production.
- If your admin workstation runs Windows 11 and you cannot find where your TLS config and cert files live, use the file-search commands from [How to Use AI-Powered Search in Windows 11: Commands and Setup](https://ai-release.org/guides/kak-ispolzovat-ii-poisk-v-windows-11-komandy-i-nastroyk.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) before editing anything.

Inventory checklist — fill it in during Step 1:

- [ ] Every HTTPS endpoint and its port
- [ ] Certificate type per endpoint (RSA / ECDSA) and expiry date
- [ ] TLS versions enabled on each listener
- [ ] Code-signing or document-signing pipelines that use RSA
- [ ] Client software that terminates TLS (load balancers, CDNs, mobile apps with pinned certs)

## Step 1. Check what your OpenSSL build can actually do

**What to do:** Confirm that the crypto library on the host ships ML-KEM (a key-encapsulation mechanism, i.e. the "key exchange" half, standardized as FIPS 203) and ML-DSA (a digital signature scheme, the "signing" half, FIPS 204). Compare it against the running endpoints on your network.

```bash
openssl version -a
openssl list -kem-algorithms | grep -i "ML-KEM"
openssl list -signature-algorithms | grep -i "ML-DSA"
openssl s_client -connect <your-domain>:443 -tls1_3 </dev/null 2>/dev/null | grep -E "Protocol|Server Temp Key"
```

**Why:** Post-quantum migration has two independent halves. Key exchange is fixed by a server config change; signatures need new certificates and new PKI support. Knowing which half your build supports tells you which change you can ship this week. The last command shows what your production endpoint negotiates today — for example `Server Temp Key: X25519, 253 bits`, which means the classical group is still in use.

**How to check:** Expect lines like `ML-KEM-768` and `ML-DSA-65` from the first two commands. If both greps return nothing, your build predates PQC support — swap the package or rebuild before continuing. Existing algorithms are still listed, so a build that prints only `RSA`/`X25519` is a pre-PQC one.

**Example:** `openssl list -signature-algorithms | grep -i "ML-DSA"` printing `ML-DSA-44`, `ML-DSA-65`, `ML-DSA-87` means the signature side is available; the number is the security level, higher is stronger and slower.

## Step 2. Turn on hybrid key exchange and generate ML-DSA keys
![Illustration: Step 2. Turn on hybrid key exchange and generate ML-DSA keys](https://ai-release.org/guides/img/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr-en-2.jpg?v=1796395324)


**What to do:** Start the lab server with the hybrid group `X25519MLKEM768`, then make a real ML-DSA keypair and sign a file. After the lab works, apply the nginx snippet to staging.

Terminal 1:

```bash
openssl s_server -accept 4433 -cert test.crt -key test.key -groups X25519MLKEM768 -tls1_3
```

Terminal 2:

```bash
openssl genpkey -algorithm ML-DSA-65 -out mldsa65.key
openssl pkey -in mldsa65.key -pubout -out mldsa65.pub
printf 'release-2026.10' > app.bin
openssl dgst -sha512 -rawin -sign mldsa65.key -out app.sig app.bin
openssl dgst -sha512 -rawin -verify mldsa65.pub -signature app.sig app.bin
wc -c mldsa65.key app.sig
```

**Why:** `X25519MLKEM768` is a hybrid group: it runs the classical X25519 exchange and the ML-KEM-768 encapsulation together and mixes both results. An attacker must break both to read the session, so you get post-quantum protection without losing compatibility. Signing with ML-DSA proves your build can produce quantum-resistant signatures before you ask a CA for a certificate.

For nginx on staging, add to the `http` or `server` block:

```nginx
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve X25519MLKEM768:X25519:P-256;
ssl_prefer_server_ciphers off;
```

**How to check:** The signing commands must end with `Verified OK`. `openssl pkey -in mldsa65.key -text -noout` should print `ML-DSA-65` as the key type, and `wc -c` shows an ML-DSA key file in the multi-kilobyte range — far larger than an RSA-2048 PEM.

**Example:** `printf 'release-2026.10' > app.bin` then a successful verify prints exactly `Verified OK`. If you see `Signature Verification failure`, the public key and private key do not belong to the same pair. Note that some builds reject `-rawin`; check the documentation for your OpenSSL version and use the signing form it lists.

## Step 3. Verify negotiation on the real endpoint
![Illustration: Step 3. Verify negotiation on the real endpoint](https://ai-release.org/guides/img/kak-podgotovitsya-k-perehodu-na-postkvantovuyu-kriptogr-en-3.jpg?v=1796395332)


**What to do:** After `nginx -t` and a reload, connect to the staging host while forcing the hybrid group, and read the negotiated parameters.

```bash
nginx -t && systemctl reload nginx
openssl s_client -connect <your-domain>:443 -tls1_3 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -E "Protocol|Cipher|Server Temp Key"
curl -sS -o /dev/null -w "%{http_code}\n" https://<your-domain>/
```

**Why:** A config line that nginx accepts is not proof the group is offered; only the handshake result proves it. Forcing `-groups` on the client removes ambiguity — if the server cannot honour it, the handshake fails instead of silently falling back to X25519.

**How to check:** Expect `Protocol: TLSv1.3`, a TLS 1.3 cipher line, and `Server Temp Key: X25519MLKEM768`. The exact formatting of that line varies between builds; what matters is the group name. `curl` must return `200`. Repeat the check from a browser on the internal test page — if you want to automate it, the setup in [How to Connect an AI Agent to Chrome: Browser Automation Setup](https://ai-release.org/guides/kak-podklyuchit-ii-agenta-k-chrome-nastroyka-avtomatiza.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) lets you script the page load and see whether the app still renders.

**Example:** Before the change the grep prints `Server Temp Key: X25519, 253 bits`; after the reload the same command prints `Server Temp Key: X25519MLKEM768`. If the number is missing or different, the hybrid group is not active on that listener.

## Troubleshooting

**Problem. nginx refuses to start after adding the group**

- Error: `nginx: [emerg] SSL_CTX_set1_curves_list("X25519MLKEM768:X25519:P-256") failed (SSL:)`
- Cause: nginx is linked against an OpenSSL build without ML-KEM, so the group name is unknown to the library.
- Solution: run `nginx -V` and read the `built with OpenSSL ...` part. If the version is older than the PQC-capable build you verified in Step 1, install a build linked against a newer OpenSSL and restart: `systemctl restart nginx`. Keep the old `ssl_ecdh_curve` line while you swap.

**Problem. Client handshake fails with a group error**

- Error: `Failed to set groups` or `no suitable key share`
- Cause: the group name is wrong for your build, or the client cannot offer it.
- Solution: retry without `-groups` to confirm the endpoint works, then check the exact group name in the documentation for your OpenSSL version and use it verbatim. On curl the same limit appears as `curl: (35) ... error: ...`.

**Problem. ML-DSA certificate breaks the client**

- Error: `no suitable signature algorithm` or `sslv3 alert handshake failure` right after you replace the certificate
- Cause: the client's trust store does not accept ML-DSA certificates yet. Hybrid key exchange fixes the session encryption, but certificates are a separate PKI problem.
- Solution: roll the certificate back to your ECDSA/RSA certificate and keep only the hybrid key exchange change live: `ssl_certificate`/`ssl_certificate_key` point at the old pair, `ssl_ecdh_curve X25519MLKEM768:X25519` stays. Use ML-DSA first for internal signing (Step 2), not for public TLS.

## Summary and next steps

You now have a verified hybrid TLS 1.3 listener, a working ML-DSA keypair, and an inventory of endpoints still using classical cryptography. Next, repeat Step 3 on every listener in the checklist, then decide with your CA when ML-DSA certificates can replace the current pair.

## FAQ

**Is ML-KEM the same thing as Kyber?**
ML-KEM is the standardized key-encapsulation mechanism derived from the Kyber submission; in TLS it is normally used in a hybrid group together with X25519, as in `X25519MLKEM768`. Check the FIPS 203 documentation for the exact definition your auditors expect.

**Do I need a new TLS certificate for post-quantum TLS?**
No. Hybrid key exchange works with your existing ECDSA or RSA certificate, which is why Step 2 is the fastest change to ship. A post-quantum certificate is only needed if you also want ML-DSA signatures on the certificate itself.

**Will old clients stop working after I enable `X25519MLKEM768`?**
If you list fallbacks, they keep working: `ssl_ecdh_curve X25519MLKEM768:X25519:P-256` lets a client that does not know the hybrid group negotiate X25519 or P-256 instead. Remove the fallbacks only after your client inventory is clean.

**Where do I start if I have hundreds of endpoints?**
Start with the checklist from Step 1 and sort by exposure: public HTTPS first, internal services second, code-signing pipelines last. Each endpoint gets the Step 3 check before you move to the next one.
