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

> Node.js builds that bundle OpenSSL 3.5 negotiate hybrid X25519MLKEM768 by default. Check your version, fix an ecdhCurve that disables it, and verify the handshake.

Source: https://pqshift.dev/learn/post-quantum-tls-nodejs · Published 2026-12-04 · Updated 2026-12-04 · pqshift

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.

## Check the bundled OpenSSL first

```bash
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

| Line | Bundled OpenSSL | Post-quantum TLS |
|---|---|---|
| Node 20 | 3.0.x | No (end of life since April 2026) |
| Node 22 (current releases) | 3.5.x | Yes |
| 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

```js
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:

```js
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

```bash
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+:

```bash
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](https://pqshift.dev/learn/test-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](https://pqshift.dev/learn/post-quantum-tls-nginx). 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](https://pqshift.dev/) 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

- [Node.js tls module documentation (ecdhCurve, DEFAULT_ECDH_CURVE)](https://nodejs.org/api/tls.html)
- [Node.js v24.16.0 release (OpenSSL 3.5.6)](https://nodejs.org/en/blog/release/v24.16.0)
- [Is your Node.js app quantum safe? Tracing PQC in TLS connections (observed OpenSSL versions per Node release)](https://dev.to/daan_acohen/is-your-nodejs-app-quantum-safe-tracing-pqc-in-tls-connections-10b8)
- [OpenSSL 3.5 release announcement](https://openssl-library.org/post/2025-03-25-openssl-3.5-beta/)
