Security

How to migrate Node.js and Python apps to post-quantum cryptography

Capy team

Upgrade containers to Node.js on OpenSSL 3.5 (24.22.3 ships 3.5.9) and Python 3.15 linked to OpenSSL 3.5, because OpenSSL 3.0 lacks X25519MLKEM768. Require TLS 1.3 with X25519MLKEM768:X25519 and verify it in tests. Rotate jose and PyJWT to ES384 via a dual-key JWKS, upgrade cryptography keys, and audit lockfiles.

How to check OpenSSL 3.5 in Node.js and Python

Both runtimes inherit post-quantum TLS from their linked OpenSSL, so check your container first; see the NSA December 2026 advisory checklist.

node -p process.versions.openssl
python -c "import ssl; print(ssl.OPENSSL_VERSION)"

OpenSSL 3.5 adds ML-KEM, ML-DSA, and RFC 10024 hybrid groups, and puts X25519MLKEM768 first by default. Node.js on OpenSSL 3.5 (24.22.3 ships 3.5.9) and the uv-managed Python 3.15 build link OpenSSL 3.5.9; distro OpenSSL 3.0 packages have no ML-KEM.

ComponentFlaggedInterimTarget
Node TLSX25519, P-256, OpenSSL 3.0X25519MLKEM768:X25519X25519MLKEM768
Node JWTsES256, EdDSA, RS256ES384 or PS384 JWKSML-DSA-65
Python TLSset_ecdh_curve(), OpenSSL 3.0set_groups on 3.15X25519MLKEM768
Python keysSECP256R1, Ed25519, RSA-2048SECP384R1, RSA-3072MLDSA65PrivateKey
Python JWTsES256, EdDSA, RS256ES384ML-DSA

How to enable X25519MLKEM768 TLS in Node.js

In Node.js on OpenSSL 3.5 (24.22.3 ships 3.5.9), default node:tls sockets already negotiate X25519MLKEM768, so audit repos for older images or ecdhCurve overrides. Set minVersion: 'TLSv1.3' and ecdhCurve: 'X25519MLKEM768:X25519' on servers and https.Agent, then drop :X25519 once peers upgrade. Check socket.getEphemeralKeyInfo() for X25519MLKEM768 on TLSv1.3 in CI; see Post-quantum TLS 1.3 for proxy behavior.

How to rotate jose JWTs to ES384 without downtime

Rotate jose signing from ES256, EdDSA, or RS256 to ES384 or PS384 in five steps:

  1. Generate an ES384 pair with generateKeyPair('ES384') and export its JWK with a new kid.
  2. Publish the old key and new ES384 key together in your JWKS.
  3. Verify tokens with createRemoteJWKSet and jwtVerify, which selects by kid.
  4. Switch issuers to sign new tokens with the new kid and a bounded exp. Keep the old key in the JWKS until every old-key token with an exp has expired and, if any were issued without exp, the cutoff in step 5 has passed. Then remove it.
  5. If older tokens were issued without exp, set a cutoff date for them and revoke or reissue them before it. Only after that cutoff, add requiredClaims: ['exp'] to the verifier, as in the verifier below. Turning it on earlier rejects those older tokens while their key is still published.
import { SignJWT, createRemoteJWKSet, exportJWK } from 'jose';
import { generateKeyPair, jwtVerify } from 'jose';

const NEW_KID = 'es384-2026-12';

const { publicKey, privateKey } = await generateKeyPair('ES384');
const newPublicJwk = {
  ...(await exportJWK(publicKey)),
  kid: NEW_KID,
};

const token = await new SignJWT({ sub: 'service-account' })
  .setProtectedHeader({ alg: 'ES384', kid: NEW_KID })
  .setIssuedAt()
  .setExpirationTime('15m')
  .sign(privateKey);

const jwks = createRemoteJWKSet(
  new URL('https://auth.example.com/.well-known/jwks.json'),
);
const { payload } = await jwtVerify(token, jwks, {
  requiredClaims: ['exp'],
});

node:crypto on OpenSSL 3.5 supports ml-dsa-65, ml-kem-768, and crypto.encapsulate; reserve ML-DSA for internal services until federated verifiers accept it. Audit node:crypto for 'ed25519', prime256v1, and modulusLength: 2048, and see Audit JWTs, SSH keys and certificates.

Run the Node.js and Python migration with Capy

Upgrading base images, TLS config, JWKS rotations, and lockfiles repo by repo stalls on CI follow-ups. Capy splits that work by repository:

  • Captains split work to one thread per repo. Each thread opens and follows its pull request; Capy never merges unless someone asks for that merge.
  • Each thread runs on an isolated cloud microVM. With the repo cloned, it runs your real test suite and TLS handshake checks before opening the PR.
  • Capy Review checks every PR. Plain-English rules in AGENTS.md ## Reviews and organization Review settings flag P-256, Ed25519, and sub-3072 RSA.
  • Automations run a stored prompt on a schedule. A weekly re-scan opens a PR when it finds new weak crypto.

See multi-repo code migrations for batch sizing and stop rules.

How to configure Python 3.15 TLS with ssl and requests

Python 3.15 adds set_groups(), get_groups(), and SSLSocket.group() to ssl, whereas older releases only expose single-curve set_ecdh_curve(). Assert s.version() == "TLSv1.3" and s.group() == "X25519MLKEM768" in CI, then drop :X25519 once peers upgrade.

import ssl

srv = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
srv.minimum_version = ssl.TLSVersion.TLSv1_3
srv.load_cert_chain("cert.pem", "key.pem")
srv.set_groups("X25519MLKEM768:X25519")

For requests, subclass HTTPAdapter to pass ssl_context via init_poolmanager for urllib3 2.x, and confirm ssl.OPENSSL_VERSION in the deployed image.

How to upgrade Python cryptography keys and PyJWT

In cryptography, change SECP256R1 to SECP384R1, raise RSA key_size to 3072, and move Ed25519 to P-384 or ML-DSA. cryptography 48.0.0 on OpenSSL 3.5 adds mldsa and mlkem, and PyJWT moves to algorithm="ES384" behind a dual-key JWKS.

from cryptography.hazmat.primitives.asymmetric import mldsa

private_key = mldsa.MLDSA65PrivateKey.generate()
data = b"signed-payload"
signature = private_key.sign(data)
private_key.public_key().verify(signature, data)

How to audit Node.js and Python lockfiles

Transitive dependencies can pin older crypto libraries:

  • Node.js. Run npm ls jose jsonwebtoken node-forge and grep package-lock.json.
  • Python. Run uv tree | grep -iE 'cryptography|pyopenssl' and inspect uv.lock or poetry.lock for cryptography under 48.0.0 or pyOpenSSL.

Skip pip-audit here because it checks advisories, not algorithms. Pair lockfile audits with scanning for RSA and ECC, blocking weak crypto in CI, and the Go migration guide.

Frequently Asked Questions

Why does Python fail to negotiate X25519MLKEM768 after code changes?+
Python uses the OpenSSL it was built against, so OpenSSL 3.0 builds have no ML-KEM. Check ssl.OPENSSL_VERSION and move to Python 3.15 on OpenSSL 3.5, such as the uv-managed 3.15 build on 3.5.9.
Does Node.js on OpenSSL 3.5 negotiate X25519MLKEM768 by default?+
Yes. Node.js on OpenSSL 3.5 (24.22.3 ships 3.5.9) puts X25519MLKEM768 first in TLS 1.3, so audit services for classical ecdhCurve overrides or older Node builds.
Why rotate JWTs to ES384 or PS384 before ML-DSA?+
Most federated verifiers reject ML-DSA today, even though jose and Node.js on OpenSSL 3.5 support ML-DSA-65. Moving to ES384 or PS384 drops P-256 and RSA-2048 now and keeps JWKS interoperability.
Can Python 3.14 set hybrid TLS groups with set_ecdh_curve?+
No. set_ecdh_curve takes one classical curve. Upgrade to Python 3.15 for set_groups, get_groups, and SSLSocket.group.

Sources

  1. Node.js documentation: TLS (SSL)
  2. panva/jose: JWA, JWS, JWE, JWT, JWK, JWKS for JavaScript
  3. Python documentation: What is New in Python 3.15
  4. pyca/cryptography: Changelog

Spotted something out of date? Tell us at support@capy.ai.

Migrate Node.js and Python services with Capy

Start one Capy thread per repository on its own isolated cloud microVM to bump base images, swap keys behind a dual-key window, run handshake tests, and open pull requests.