Post-quantum TLS in Node.js: X25519MLKEM768 with OpenSSL 3.5

On this page
  1. The 30-second check
  2. Which Node versions bundle OpenSSL 3.5
  3. Fix: an ecdhCurve that drops the hybrid group
  4. Fix: the runtime image
  5. Verify the handshake
  6. Behind a proxy or load balancer
  7. Application-level RSA and ECDH

Short answer: Node.js negotiates hybrid post-quantum TLS (X25519MLKEM768) by default when it is built with OpenSSL 3.5 or later and your code leaves ecdhCurve at its default. Current Node 22 and Node 24 releases bundle OpenSSL 3.5. Node 20 (OpenSSL 3.0) cannot. The usual reasons a service isn't post-quantum are an old runtime image or an ecdhCurve option that pins classical curves.

The 30-second check

node -p "process.versions.openssl"   # needs 3.5.0 or later
grep -rn "ecdhCurve\|DEFAULT_ECDH_CURVE" --include=*.{js,ts,mjs,cjs} . | grep -v node_modules

If OpenSSL is 3.5+ and nothing sets ecdhCurve, your Node TLS clients and servers already offer the hybrid group.

Which Node versions bundle OpenSSL 3.5

LineBundled OpenSSLPost-quantum TLS
Node 203.0.xNo (end of life since April 2026)
Node 22 (current releases)3.5.xYes
Node 24 (current releases)3.5.x (24.16.0 ships 3.5.6)Yes

Early Node 22 and 24 releases shipped OpenSSL 3.0, so a pinned patch version can still be classical. Always check process.versions.openssl on the exact image you deploy. Distribution builds (apt install nodejs, some Alpine packages) may link the system OpenSSL instead of the bundled one, so check those too.

Fix: an ecdhCurve that drops the hybrid group

import https from "node:https";

// Before: classical only
const server = https.createServer({ key, cert, ecdhCurve: "P-256:P-384" }, app);

// After: hybrid first, classical kept as a fallback
const server = https.createServer({
  key, cert,
  minVersion: "TLSv1.2",
  ecdhCurve: "X25519MLKEM768:X25519:P-256:P-384",
}, app);

ecdhCurve is a colon-separated list passed to OpenSSL, so any OpenSSL 3.5 group name works. The same option applies to tls.connect(), https.request() agents and tls.createSecureContext(). Keep X25519 and P-256 in the list: clients without ML-KEM support (and TLS 1.2 connections) then still connect.

If code sets the process-wide default, fix that too:

import tls from "node:tls";
tls.DEFAULT_ECDH_CURVE = "X25519MLKEM768:X25519:P-256:P-384"; // or just leave it at "auto"

On a runtime with OpenSSL older than 3.5, X25519MLKEM768 is an unknown name and the context will fail to build. Upgrade the runtime before (or together with) the config change.

Fix: the runtime image

cat .nvmrc .node-version 2>/dev/null
grep -n '"node"' package.json            # engines
grep -rn "FROM node:" Dockerfile*
grep -rn "node-version" .github/workflows/

Move each to a current Node 22 or 24 release and rebuild.

Verify the handshake

Against a Node server, from a machine with OpenSSL 3.5+:

openssl s_client -connect your-service.example:443 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -i group

For a Node client, connect to a server known to support the hybrid group (for example pq.cloudflareresearch.com) and inspect it from the server side, or capture the handshake with Wireshark, which decodes the key share group. Details in How to check if a server uses post-quantum TLS.

Behind a proxy or load balancer

If TLS terminates at nginx, a cloud load balancer or a CDN, the Node process's settings don't decide what browsers negotiate. Check the terminating layer: see the nginx and OpenSSL server guide. Internal service-to-service hops are still worth fixing, since that traffic is just as recordable.

Application-level RSA and ECDH

crypto.publicEncrypt() with RSA and crypto.createECDH() / diffieHellman() used to wrap keys are quantum-vulnerable in the same harvest-now-decrypt-later way. They need a code change to a hybrid KEM, not a config flag, and old ciphertexts must still decrypt. pqshift flags these and proposes a versioned hybrid scheme in a reviewable PR.

FAQ

Which Node.js versions support post-quantum TLS?

Releases that bundle OpenSSL 3.5 or later. Current Node 22 and Node 24 releases do (check process.versions.openssl); Node 20 ships OpenSSL 3.0 and cannot negotiate X25519MLKEM768.

How do I enable X25519MLKEM768 in Node.js?

On OpenSSL 3.5 it is on by default when ecdhCurve is left at 'auto'. If you set ecdhCurve, put X25519MLKEM768 first, for example ecdhCurve: 'X25519MLKEM768:X25519:P-256:P-384'.

Sources