nginx post quantum nginx post quantum tls nginx post quantum cryptography

Nginx post-quantum TLS: how to enable X25519MLKEM768

Adrian Maverick · · 8 min read

To enable post-quantum TLS in nginx, run an nginx that is linked against OpenSSL 3.5 or newer and make sure ssl_ecdh_curve includes X25519MLKEM768. If you have never set ssl_ecdh_curve, the default auto already uses OpenSSL's built-in list, which on 3.5 puts X25519MLKEM768 first.

So for many servers the work is an OpenSSL upgrade, or deleting an old pinned curve list. This guide covers the version check, the exact directive, a stricter variant that insists on ML-KEM, and two ways to prove it worked.

X25519MLKEM768 is a hybrid key exchange: classical X25519 plus ML-KEM-768 from NIST's FIPS 203. It protects today's traffic against harvest now, decrypt later. IANA lists it as group 4588 and marks it Recommended.

What you need

Requirement Why
OpenSSL 3.5.0 or later, linked into nginx OpenSSL added ML-KEM and the hybrid TLS groups in 3.5.0
TLS 1.3 enabled The ML-KEM groups only appear in OpenSSL's TLS 1.3 group list
nginx 1.11.0 or later ssl_ecdh_curve accepts a list of groups from 1.11.0

TLS 1.3 is on by default since nginx 1.23.4 (ssl_protocols TLSv1.2 TLSv1.3), so only very old configs need a change there.

The OpenSSL version is the part that trips people up, because nginx uses whatever library it was built against. Here is what the main server distributions ship, checked on their package sites today:

Distribution OpenSSL package Post-quantum groups
Debian 13 (trixie) 3.5.9 Yes
Ubuntu 26.04 LTS (resolute) 3.5.5 Yes
Debian 12 (bookworm) 3.0.22 No
Ubuntu 24.04 LTS (noble) 3.0.13 No

On Debian 12 or Ubuntu 24.04 you need a newer OS release or an nginx build that bundles OpenSSL 3.5. The OpenSSL 3.5 branch is a long-term support release, supported until April 8, 2030, according to the OpenSSL downloads page.

Step 1: check which OpenSSL nginx uses

Run:

nginx -V 2>&1 | grep -i openssl

nginx -V prints the version, compiler and configure parameters. Look for the OpenSSL line and its version number. Checking openssl version on the host is not enough: a custom or vendor build can bundle its own copy, and the command-line tool can be a different build from the library nginx loads.

If it says 3.0.x or 1.1.1, stop here and upgrade. No directive will add ML-KEM to an older library.

Step 2: look for a pinned curve list

Search your config:

grep -rn "ssl_ecdh_curve\|ssl_conf_command" /etc/nginx/

The nginx docs say the default value, auto, "instructs nginx to use a list built into the OpenSSL library." OpenSSL's 3.5 release notes say that built-in list now includes and prefers hybrid post-quantum groups, and that clients send key shares for X25519MLKEM768 and X25519 by default.

If grep finds nothing, you are already done once OpenSSL is 3.5 or later. Skip to verification.

If it finds a pinned list without an ML-KEM group, such as ssl_ecdh_curve X25519:prime256v1:secp384r1;, that list replaces OpenSSL's default and leaves post-quantum key exchange off. Also check for an ssl_conf_command Groups ... or Curves ... line, which sets the same thing through OpenSSL directly.

Step 3: set ssl_ecdh_curve

Put the directive in the http block so every server uses the same list:

http {
    ssl_protocols  TLSv1.2 TLSv1.3;
    ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1:secp384r1;

    server {
        listen 443 ssl;
        server_name example.com;
        ssl_certificate     /etc/nginx/ssl/example.com.crt;
        ssl_certificate_key /etc/nginx/ssl/example.com.key;
    }
}

What each part does:

  • X25519MLKEM768 first makes it the preferred group for clients that offer it.
  • X25519, prime256v1 and secp384r1 keep classical key exchange for clients that do not, including every TLS 1.2 client. Keep the curve your certificate uses: the nginx docs warn that ECDSA certificates need their curve in this list.
  • Colons separate groups. Group names are case-insensitive in OpenSSL 3.5 and later.

Then test and reload:

nginx -t && nginx -s reload

On an OpenSSL older than 3.5, nginx -t fails here. nginx passes the string straight to OpenSSL's SSL_CTX_set1_curves_list(), and OpenSSL's documentation says an unknown group name "will cause a failure to parse the list." That failure is a useful guard against shipping a config to a host that cannot do ML-KEM.

Stricter: make the server ask for ML-KEM

With a plain colon list, OpenSSL treats every group as one tier. If a client supports X25519MLKEM768 but only sent an X25519 key share, the server accepts X25519 to save a round trip. OpenSSL's group list documentation puts it this way: "Within a tuple, existing keyshares trump preference order."

OpenSSL 3.5 added tuples, separated by /, to change that:

ssl_ecdh_curve X25519MLKEM768/X25519:prime256v1:secp384r1;

Now X25519MLKEM768 is its own top tier. A client that supports it but did not send its key share gets a HelloRetryRequest and comes back with ML-KEM. The cost is one extra round trip for those clients. Clients that never offer ML-KEM still connect with the second tier.

Run the latest 3.5.x patch release if you use this syntax. OpenSSL 3.5.6 fixed CVE-2026-2673, a bug that lost the tuple structure when the DEFAULT keyword was used in a server-side group list.

Step 4: verify it works

From outside, with OpenSSL 3.5 or later on your machine:

openssl s_client -connect example.com:443 -servername example.com -groups X25519MLKEM768 -brief </dev/null

-groups X25519MLKEM768 makes the client offer only the hybrid group. In our test today against a server with support, the output included:

Negotiated TLS1.3 group: X25519MLKEM768

A server without support refused the handshake with ssl/tls alert handshake failure and SSL alert number 40. For browser checks, curl and a script for many hosts, see how to check if a website uses post-quantum encryption.

From inside, with your access log. The s_client test proves the server can do it. The log shows what real visitors get. nginx's $ssl_curve variable holds the negotiated key exchange group:

http {
    log_format pq '$remote_addr [$time_local] "$request" $ssl_protocol $ssl_curve';
    access_log /var/log/nginx/pq.log pq;
}

After a reload, count groups:

awk '{print $NF}' /var/log/nginx/pq.log | sort | uniq -c | sort -rn

Two things to know. The nginx docs say unknown groups are shown in hexadecimal, so you may see 0x11ec: that is 4588, the IANA code for X25519MLKEM768. And nginx 1.27.5 fixed a bug in $ssl_curve and $ssl_curves with OpenSSL's pluggable groups. Debian 13 packages nginx 1.26.3, which is older than that fix, so if the value looks wrong, trust the s_client test or move to a current nginx (mainline 1.31.10, stable 1.30.8 today).

Gotchas

  • TLS 1.2 clients never get ML-KEM. That is expected. They keep using the classical groups in your list.
  • The device that terminates TLS is the one that matters. Behind a CDN or load balancer, configure that layer too. Your nginx origin only negotiates with whatever connects to it.
  • Upstream connections are separate. When nginx proxies to an HTTPS backend, it is the client. proxy_ssl_conf_command passes OpenSSL commands for that connection, for example proxy_ssl_conf_command Groups X25519MLKEM768:X25519;. OpenSSL 3.5 already offers X25519MLKEM768 to upstreams by default.
  • The stream module has its own copy. TLS on raw TCP through ngx_stream_ssl_module uses its own ssl_ecdh_curve, with the same syntax.
  • Bigger handshakes. OpenSSL's docs say hybrid key shares are about 1,200 bytes, and warn that the larger ClientHello can trip some firewalls. Roll out in stages if old middleboxes sit in front of you.
  • Your certificate is still classical. This change protects the key exchange, which is what harvest now, decrypt later targets. Signatures are a separate migration.

Frequently asked questions

Does nginx support ML-KEM?

Yes, through OpenSSL. nginx has no ML-KEM code of its own. It uses the groups the linked OpenSSL provides, and OpenSSL 3.5 added X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024.

Which nginx version do I need for post-quantum TLS?

Any nginx from 1.11.0 can pass a list of groups, but the OpenSSL version decides whether ML-KEM is there. For the $ssl_curve log check, use nginx 1.27.5 or later to get readable names.

Can I use ML-KEM-1024 in nginx?

You can list SecP384r1MLKEM1024. OpenSSL's docs say it is "substantially more CPU-intensive" than the X25519 hybrid, with key exchange messages close to 1,700 bytes. It only helps with clients that offer it, so keep X25519MLKEM768 in the list too.

Does post-quantum TLS slow nginx down?

OpenSSL describes the hybrid groups as offering "CPU performance comparable to the associated ECDH group," with larger key exchange messages. Measure on your own traffic, but for most sites the difference is bytes, not CPU.

Do I need a post-quantum certificate?

No, not for this. Key exchange and certificates are separate. Your existing RSA or ECDSA certificate keeps working with X25519MLKEM768.

Where Secria fits

Web traffic is one item on the list. Mail is another. Secria is a private workspace with Mail, Calendar, Drive and Pages, plus Secria VPN, in one account. Secria Mail uses ML-KEM-1024 with X25519 on every plan, and Secria VPN adds an ML-KEM-1024 key to WireGuard on every connection. For teams of 3 or more, it runs on your own domain with SPF, DKIM and DMARC checked. Read how Secria encrypts your data.

For the wider plan and the deadlines behind it, see the December 2026 post-quantum joint statement. If the Anthropic lattice papers are why you are here, read is ML-KEM broken first.

Secria fact-checks every post against primary sources. Spotted something wrong or out of date? Email hq@secria.me and we will correct it.