Sanniv Khare 6 min read

Post-quantum TLS on nginx: X25519MLKEM768 in one config line

Post-quantum TLS on nginx: X25519MLKEM768 in one config line

Short answer: if your nginx is built against OpenSSL 3.5 or later, it can already negotiate the hybrid post-quantum group X25519MLKEM768. Two things decide whether it does. A hardened ssl_ecdh_curve line copied from an older guide (X25519:prime256v1, for example) silently turns it off. And on nginx built with OpenSSL 3.0, the default on Ubuntu 24.04, adding X25519MLKEM768 to that line makes nginx -t fail. Run nginx -V first, then set ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1;, and log $ssl_curve to confirm.

We tested this on a Linux test server (Ubuntu 24.04) with nginx 1.30.8 built against OpenSSL 3.5.10, a second nginx 1.30.8 built against the system OpenSSL 3.0.13, and openssl s_client from both OpenSSL versions as the client.

Why we did this: today we published the client half, what URLSession and CryptoKit do on iOS 26. Our React Native banking apps talk to nginx backends, and an iPhone that offers X25519MLKEM768 only gets it if the server agrees.

Why this is on everyone’s list this week

On 1 December the NSA published an advisory urging an immediate move to post-quantum cryptography, and Filippo Valsorda’s reading of it (2 Dec) puts TLS key exchange first: get connections to X25519MLKEM768 now, because traffic recorded today can be decrypted later. Clients are already there. Apple’s support note on quantum-secure TLS says iOS 26, iPadOS 26, macOS Tahoe 26 and visionOS 26 advertise X25519MLKEM768 in every TLS 1.3 ClientHello. Whether the connection uses it is the server’s choice.

X25519MLKEM768 is a hybrid: the key share combines classical X25519 with ML-KEM-768, so the connection is at least as strong as X25519 alone even if one half turns out weak.

Step 1: check what your nginx was built with

The group comes from the OpenSSL library nginx links against, not from nginx itself. Look at the third line:

nginx -V 2>&1 | grep -i openssl
# built with OpenSSL 3.5.10 1 Dec 2026     <- can do X25519MLKEM768
# built with OpenSSL 3.0.13 30 Jan 2024    <- cannot

OpenSSL added ML-KEM and the hybrid groups in 3.5.0 (8 April 2025). The 3.5 release notes also say the default supported groups were changed “to include and prefer hybrid PQC KEM groups”, and that the default key shares are now X25519MLKEM768 and X25519.

Platform OpenSSL Post-quantum groups Source
Ubuntu 22.04 LTS 3.0.2 No ServerPilot OpenSSL table
Ubuntu 24.04 LTS 3.0.13 No Same table; matches our test server
Ubuntu 26.04 LTS 3.5.5 Yes Same table; nginx package is 1.28.3
Debian 13 3.5.x Yes NGINX community blog
Debian 12 3.0.x No Same post
Your own build 3.5 or later Yes Build with --with-openssl= pointing at a 3.5 source tree

If you run a panel such as CloudPanel, it ships its own nginx build, so the nginx -V line is the only answer that counts for that server.

Step 2: the one line

nginx’s ssl_ecdh_curve defaults to auto, which means “use the list built into OpenSSL”. With OpenSSL 3.5 that list already puts the hybrid group first. The problem is the many hardened configs that set the list explicitly and predate ML-KEM.

nginx config before and after: ssl_ecdh_curve with and without X25519MLKEM768

Both configs ran on nginx 1.30.8 with OpenSSL 3.5.10; the comment shows what $ssl_curve logged for an OpenSSL 3.5 client.

server {
    listen 443 ssl;
    http2 on;
    ssl_protocols TLSv1.2 TLSv1.3;
    # hybrid first, then classical fallbacks
    ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1;
    ...
}

Keep prime256v1 in the list if your certificate is ECDSA P-256: the nginx docs note that the list must include the curves your certificates use. We also tested the longer X25519MLKEM768:X25519:prime256v1:secp384r1; it behaves the same.

Step 3: verify it in your own logs

$ssl_curve (nginx 1.21.5 and later, OpenSSL 3.0 or later) logs the negotiated group per connection. Add a log format and you can count how many of your real visitors already use post-quantum key exchange:

log_format tls '$remote_addr $ssl_protocol $ssl_curve $ssl_cipher';
access_log /var/log/nginx/tls.log tls;

From the command line, an OpenSSL 3.5 client prints the group directly:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | grep 'Negotiated TLS1.3 group'
# Negotiated TLS1.3 group: X25519MLKEM768

On a Mac with Tahoe 26, Apple’s note gives nscurl --tls-diagnostics https://example.com, which reports the key exchange group too.

What we saw: five handshakes

We ran three server configs (no ssl_ecdh_curve, a classical-only list, and the hybrid list) against an OpenSSL 3.5.10 client and an OpenSSL 3.0.13 client.

Table of server config, client and negotiated group for five handshakes

Real output from our test server, summarised from openssl s_client and the $ssl_curve access log.

  • No ssl_ecdh_curve at all: X25519MLKEM768. On OpenSSL 3.5 the default is already post-quantum.
  • Classical-only list: X25519. Nothing breaks, nothing warns; the server just never picks the hybrid group.
  • Hybrid list: X25519MLKEM768 for the new client, X25519 for the old one. Fallback works.
  • Classical-only server, client offering only X25519MLKEM768: handshake failure, alert 40. Today’s clients always offer a classical fallback, so this only matters for clients you configure yourself.

The OpenSSL 3.0 trap

Copying the hybrid line onto nginx built with OpenSSL 3.0 does not degrade gracefully. nginx -t rejects it, and a reload with that config would fail:

nginx -t failing with group X25519MLKEM768 cannot be set

Real output from our test server. Only the path of the config file is shortened.

OpenSSL 3.5 accepts a ? prefix (?X25519MLKEM768) meaning “skip this group if unknown”, but OpenSSL 3.0 does not understand the prefix either: we got the same error with it. If one config file is shared across servers with different OpenSSL builds, keep the line in a per-server include, or upgrade OpenSSL first. The NGINX blog lists an OQS provider route for OpenSSL 3.0; we have not used it.

Bigger handshakes, and the middlebox problem

Post-quantum key shares are large. With openssl s_client -msg we read the handshake message lengths:

Message OpenSSL 3.0.13 client OpenSSL 3.5.10 client
ClientHello 304 bytes 1,535 bytes
ServerHello (hybrid list on server) 122 bytes 1,210 bytes

A 1,535-byte ClientHello no longer fits in one TCP segment on a normal 1,500-byte MTU path, so it arrives in two packets. Some older load balancers, firewalls and TLS-inspecting proxies only read the first packet and drop or reset the connection. Apple’s note calls this out and links tldr.fail. If nginx sits behind an older appliance, test from outside with an OpenSSL 3.5 client or a current browser after the change, not only on the server itself.

Checklist

  1. nginx -V: OpenSSL 3.5 or later? If not, plan the OpenSSL or OS upgrade first.
  2. Search your config for ssl_ecdh_curve. No line at all on OpenSSL 3.5 already means post-quantum by default.
  3. If there is a line, put X25519MLKEM768 first and keep the curve your certificate uses.
  4. nginx -t, reload, then check $ssl_curve in the log and one s_client run from outside.
  5. Watch error rates for a day for clients behind old middleboxes.

Made by the team behind this post

Apps from our studio

  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.