← All guides AI Release
RU Subscribe to @ai_releaseorg

Step-by-step: enabling post-quantum ML-KEM (X25519MLKEM768) key exchange in OpenSSL 3.5 and nginx

Updated: 06.12.2026 · AI Release · @ai_releaseorg
Step-by-step: enabling post-quantum ML-KEM (X25519MLKEM768) key exchange in OpenSSL 3.5 and nginx

🤖 AI summary

Which topics does it cover?
как включить ML-KEM в OpenSSL, постквантовый TLS настройка nginx, X25519MLKEM768 проверка handshake, openssl 3.5 quantum safe →

TL;DR

What you will get

Quick start

openssl version -a
openssl list -kem-algorithms | grep -i ml-kem
sudo nginx -V 2>&1 | tr ' ' '\n' | grep -i openssl
openssl s_client -connect <your-domain>:443 -tls1_3 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -E "Protocol|Group|Server Temp Key"

Details and checks are in the steps below.

Requirements and setup

Illustration: Requirements and setup
Illustration: Requirements and setup

If nginx runs on a self-hosted or home box and you also plan to put other services behind it, the layout described in How to add AI to your home server: self-hosted services guide keeps ports and reverse-proxy rules in one place.

Example: on Ubuntu, sudo apt install build-essential libpcre2-dev zlib1g-dev gives you the toolchain needed for an nginx source build.

Step 1. Confirm your OpenSSL 3.5 provides ML-KEM and the hybrid group

What to do: check the library version, list the KEM algorithms, and run a local loopback handshake that forces the hybrid group.

Why: a huge share of "it doesn't work" cases are simply an old library. If the library has no ML-KEM, no nginx directive will produce it. Testing on 127.0.0.1 first isolates the library from nginx configuration.

openssl version -a
openssl list -kem-algorithms | grep -i ml-kem

Expected: the version line reports OpenSSL 3.5.x, and the second command prints ML-KEM entries (for example ML-KEM-768). If the second command prints nothing, the provider is missing — see Troubleshooting.

Now create a throwaway certificate and run a local TLS 1.3 server limited to the hybrid group:

openssl req -x509 -newkey rsa:2048 -nodes -days 1 \
  -keyout /tmp/server.key -out /tmp/server.crt -subj "/CN=localhost"
openssl s_server -accept 4433 -cert /tmp/server.crt -key /tmp/server.key \
  -tls1_3 -groups X25519MLKEM768

In a second terminal:

openssl s_client -connect 127.0.0.1:4433 -tls1_3 -groups X25519MLKEM768 </dev/null 2>/dev/null \
  | grep -E "Protocol|Group|Server Temp Key"

How to check: the client output contains a line with X25519MLKEM768 (typically a Server Temp Key: or Group: line) and Protocol: TLSv1.3. Press Ctrl+C in the s_server terminal when done. This works because both sides are the same 3.5 library, so the group is guaranteed to be offered.

Step 2. Point nginx at OpenSSL 3.5 and add the group directive

Illustration: Step 2. Point nginx at OpenSSL 3.5 and add the group directive
Illustration: Step 2. Point nginx at OpenSSL 3.5 and add the group directive

What to do: verify which OpenSSL nginx is actually linked against, rebuild nginx if needed, then add one config file.

Why: nginx does not use the openssl binary; it links the library at build time. A system nginx can be linked to 3.0 while /usr/local/bin/openssl reports 3.5 — the openssl s_client test passes, the browser handshake does not.

Check the linkage:

nginx -V 2>&1 | tr ' ' '\n' | grep -i openssl
ldd "$(command -v nginx)" | grep -i ssl

If both show 3.5, skip the rebuild. Otherwise build nginx against the 3.5 tree:

cd /usr/local/src
tar xf nginx-<nginx-version>.tar.gz && cd nginx-<nginx-version>
./configure --with-http_ssl_module \
  --with-openssl=/usr/local/src/openssl-3.5.x \
  --with-openssl-opt=shared
make -j"$(nproc)" && sudo make install

<nginx-version> is the release you downloaded; --with-openssl= points at the OpenSSL 3.5 source directory. Check your nginx release notes for the exact configure flags you need — the directive set depends on the build.

Now the server block. Create /etc/nginx/conf.d/pq.conf:

server {
    listen 443 ssl;
    server_name <your-domain>;

    ssl_certificate     /etc/nginx/ssl/<your-domain>.crt;
    ssl_certificate_key /etc/nginx/ssl/<your-domain>.key;

    ssl_protocols TLSv1.3 TLSv1.2;
    ssl_prefer_server_ciphers off;

    # Offer the hybrid post-quantum group first, classical groups as fallback
    ssl_conf_command Groups X25519MLKEM768:X25519:P-256;

    location / {
        return 200 "pq-ok\n";
        add_header Content-Type text/plain;
    }
}

The Groups list is an OpenSSL setting, not an nginx one — ssl_conf_command is the pipe that hands it to the SSL context. Keeping X25519 and P-256 in the list means clients without ML-KEM still connect, just classically.

Load it:

sudo nginx -t && sudo systemctl reload nginx

How to check: sudo nginx -t prints syntax is ok and test is successful. Then curl -s https://<your-domain>/ returns pq-ok. If you see unknown directive "ssl_conf_command", your nginx is too old — see Troubleshooting.

Step 3. Verify the negotiated group from a client

Illustration: Step 3. Verify the negotiated group from a client
Illustration: Step 3. Verify the negotiated group from a client

What to do: handshake against the live server with the hybrid group forced, and inspect what was negotiated.

Why: a reload proves the config parsed; only the handshake proves the group was offered and accepted.

openssl s_client -connect <your-domain>:443 -servername <your-domain> -tls1_3 \
  -groups X25519MLKEM768 </dev/null 2>/dev/null \
  | grep -E "Protocol|Group|Server Temp Key|Cipher"

How to check: success looks like Protocol: TLSv1.3 plus a line naming X25519MLKEM768 (for example Server Temp Key: X25519MLKEM768). If the output shows only X25519 or P-256, the server did not offer the hybrid group — the library linked into nginx is not 3.5, or the directive was not applied to that server block.

Run this checklist before you call it done:

What to verifyCommandExpected
Library has ML-KEMopenssl list -kem-algorithmsML-KEM entries
nginx linkagenginx -Vbuilt with OpenSSL 3.5.x
Server offers hybridopenssl s_client ... -groups X25519MLKEM768X25519MLKEM768 in output
Fallback worksopenssl s_client ... -groups X25519handshake succeeds

Troubleshooting

Problem. nginx refuses to start with an unknown directive

Problem. Config loads, but the handshake still shows a classical group

Problem. Browser or old client fails while s_client succeeds

While you are in the host's patch routine, note that the same discipline — verifying what is actually running rather than what is installed — applies to OS updates; the mechanics for Windows hosts are covered in How to Enable Hotpatch Updates on Windows Server: Step-by-Step Guide.

Summary and next steps

You now have nginx serving TLS 1.3 with X25519MLKEM768 offered first and classical groups as fallback, verified end to end with openssl s_client. Next, re-run the Step 3 command after every nginx upgrade, because a distro update can silently relink nginx against an older OpenSSL and drop the hybrid group.

FAQ

What is X25519MLKEM768?

It is a hybrid key-exchange group: a classical X25519 exchange combined with ML-KEM-768, a post-quantum KEM. The handshake stays secure if either half is broken, which is why it is deployed as a hybrid rather than ML-KEM alone.

Does enabling it break old clients?

No, provided you keep classical groups in the Groups list and TLSv1.2 in ssl_protocols. Legacy clients simply negotiate X25519 or P-256; only TLS 1.3 clients that also support ML-KEM get the hybrid group.

Why does openssl s_client show ML-KEM but my browser does not?

The browser must support the same group and must use TLS 1.3. If s_client succeeds and the browser does not, the limitation is on the client side — check the browser's TLS key-exchange support in its release notes.

Do I need to change my certificate?

No. ML-KEM here affects key exchange only; your existing RSA or ECDSA certificate and key are used unchanged. Post-quantum signatures are a separate topic — check the OpenSSL 3.5 documentation for what your build supports.

🤖 AI summary

AI Release Knowledge Layer
Machine-readable description · Version 1.0

Status: practical guide. Some statements come from vendors; verify in your environment.

1. Summary

Time to complete: 30–45 minutes (plus nginx rebuild time if your package links an older OpenSSL) Difficulty: Intermediate

Inside: direct answers, key facts, entities, context, reliability, unknowns and sources.

Machine data: Citation Map JSON · JSON-LD · Semantic Embeddings — separate stage.

Full Knowledge Layer: sections 2–8

2. Direct answers

What is required?
OS: any Linux distribution with a package manager; commands below use apt paths (/etc/nginx/conf.d/). On RHEL-family systems the equivalent include directory is usually /etc/nginx/conf.d/ as well — verify with nginx -V.; OpenSSL 3.5.x installed or built from source. ML-KEM (Module-Lattice-Based Key-Encapsulation… → details (AR-GUIDE-POSHAGOVOE-003)
How to do it?
Step 1. Confirm your OpenSSL 3.5 provides ML-KEM and the hybrid group → Step 2. Point nginx at OpenSSL 3.5 and add the group directive → Step 3. Verify the negotiated group from a client → details (AR-GUIDE-POSHAGOVOE-004)
Which topics does it cover?
как включить ML-KEM в OpenSSL, постквантовый TLS настройка nginx, X25519MLKEM768 проверка handshake, openssl 3.5 quantum safe → details (AR-GUIDE-POSHAGOVOE-002)
What are the key points?
Time to complete: 30–45 minutes (plus nginx rebuild time if your package links an older OpenSSL) Difficulty: Intermediate → details (AR-GUIDE-POSHAGOVOE-007)

3. Key facts

  1. Time to complete: 30–45 minutes (plus nginx rebuild time if your package links an older OpenSSL) — evidence; status: заявление источника.
  2. Difficulty: Intermediate — evidence; status: заявление источника.
  3. You will need: a Linux host with root/sudo, OpenSSL 3.5.x, nginx with the ssl_conf_command directive, a TLS certificate for <your-domain>, and a way to reach port 443 from a test machine — evidence; status: заявление источника.
  4. OS: any Linux distribution with a package manager; commands below use apt paths (/etc/nginx/conf.d/). On RHEL-family systems the equivalent include directory is usually /etc/nginx/conf.d/ as well — verify with nginx -V. — evidence; status: заявление источника.
  5. OpenSSL 3.5.x installed or built from source. ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism, the NIST post-quantum standard) first appears in this line; older 1.1.1/3.0 builds do not have it. — evidence; status: заявление источника.
  6. nginx new enough to support the ssl_conf_command directive (it passes arbitrary OpenSSL configuration commands into the SSL context). If nginx -V does not show your OpenSSL 3.5 build, you must rebuild nginx against it — see Step 2. — evidence; status: заявление источника.

4. Entities

EntityTypeRole
как включить ML-KEM в OpenSSLтема/инструментупоминается в заголовке, TL;DR или разделах гайда
постквантовый TLS настройка nginxтема/инструментупоминается в заголовке, TL;DR или разделах гайда
X25519MLKEM768 проверка handshakeпродукт/модельупоминается в заголовке, TL;DR или разделах гайда
openssl 3.5 quantum safeпродукт/модельупоминается в заголовке, TL;DR или разделах гайда
Linuxплатформа/технологияупоминается в заголовке, TL;DR или разделах гайда

5. Context

  • Guide — describes → Step-by-step: enabling post-quantum ML-KEM (X25519MLKEM768) key exchange in OpenSSL 3.5 and nginx (AR-GUIDE-POSHAGOVOE-001).
  • Guide — includes step → Step 1. Confirm your OpenSSL 3.5 provides ML-KEM and the hybrid group (AR-GUIDE-POSHAGOVOE-001).

6. Reliability

Confirmed

No independent confirmation is provided; source claims and editorial conclusions are separated below.

Source claims

  • Product features, versions, prices and limits come from vendors and the guide.
  • Commands and steps are recommendations, not guaranteed results.

AI Release analysis

  • Structure, comparison and selection criteria are editorial.
  • The guide does not replace an independent audit or legal advice.

7. Unknowns

  • Current versions, prices and limits.
  • Independent benchmarks and quality checks.
  • Terms of use and data policy.

8. Sources

SourceTypeRole
No external links——

Cite as: AI Release. Пошаговое руководство: как включить постквантовый обмен ключами ML-KEM (X25519MLKEM768) в OpenSSL 3.5 и nginx. ai-release.org.