Post-quantum TLS in Java: JDK 27 hybrid key exchange, jdk.tls.namedGroups and ML-KEM

On this page
  1. The 30-second check
  2. Default behaviour on JDK 27
  3. Configure groups globally
  4. Configure groups per socket
  5. Spring Boot, Netty and Tomcat
  6. On JDK 21 or 25 LTS
  7. ML-KEM directly: the KEM API (JDK 24+)
  8. Verify the handshake

Short answer: JDK 27 (released September 2026) is the first JDK with hybrid post-quantum TLS built in. JEP 527 adds X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024 to TLS 1.3 and puts X25519MLKEM768 first in the default list, so a JDK 27 client sends two key shares (X25519MLKEM768 and x25519) without any code change. On older JDKs you need a newer runtime or a provider such as Bouncy Castle's JSSE.

The 30-second check

java -version                                   # JDK 27+ for built-in hybrid TLS
grep -rn "jdk.tls.namedGroups\|setNamedGroups" .
grep -rn "server.ssl\|SslContextBuilder" --include=*.{java,kt,yml,yaml,properties} .

Default behaviour on JDK 27

The default named-group order is:

X25519MLKEM768, x25519, secp256r1, secp384r1, secp521r1, x448,
ffdhe2048, ffdhe3072, ffdhe4096, ffdhe6144, ffdhe8192

The hybrid groups only apply to TLS 1.3. TLS 1.2 connections keep using classical ECDHE, which is why the classical entries must stay.

Configure groups globally

java -Djdk.tls.namedGroups="X25519MLKEM768,x25519,secp256r1,secp384r1" -jar app.jar

If your deployment already sets jdk.tls.namedGroups (common in hardened images and FIPS profiles), that list replaces the default, and the hybrid group is off until you add it. This is the most common reason a JDK 27 service isn't post-quantum.

Configure groups per socket

SSLSocket sock = (SSLSocket) SSLContext.getDefault().getSocketFactory().createSocket();
SSLParameters params = sock.getSSLParameters();
params.setNamedGroups(new String[] {
    "X25519MLKEM768", "SecP256r1MLKEM768", "x25519", "secp256r1"
});
sock.setSSLParameters(params);

The same SSLParameters approach works for SSLEngine, and for HttpClient via HttpClient.newBuilder().sslParameters(params).

Spring Boot, Netty and Tomcat

These all sit on JSSE (or on OpenSSL through netty-tcnative). On JDK 27 with JSSE, they inherit the default list or jdk.tls.namedGroups. If you run Netty or Tomcat with the OpenSSL engine, the linked OpenSSL version decides instead: it needs OpenSSL 3.5+, as in the OpenSSL server guide.

On JDK 21 or 25 LTS

The built-in JSSE provider in those releases has no hybrid TLS groups. Your options:

  1. Move the service to JDK 27 or later.
  2. Check whether your JDK vendor has backported JEP 527 to your LTS line.
  3. Use Bouncy Castle's JSSE provider (BCJSSE), which supports the hybrid ML-KEM groups, or terminate TLS in front of the JVM with a proxy linked to OpenSSL 3.5+.

ML-KEM directly: the KEM API (JDK 24+)

JDK 24 added ML-KEM (JEP 496) behind the generic javax.crypto.KEM API from JDK 21:

KeyPairGenerator g = KeyPairGenerator.getInstance("ML-KEM-768");
KeyPair kp = g.generateKeyPair();

KEM kem = KEM.getInstance("ML-KEM");
// Sender
KEM.Encapsulated enc = kem.newEncapsulator(kp.getPublic()).encapsulate();
SecretKey senderKey = enc.key();
byte[] ciphertext = enc.encapsulation();
// Receiver
SecretKey receiverKey = kem.newDecapsulator(kp.getPrivate()).decapsulate(ciphertext);

For replacing RSA key wrapping (Cipher.getInstance("RSA/ECB/OAEP...")), keep it hybrid: combine the ML-KEM secret with an X25519 KeyAgreement secret through a KDF, and version the ciphertext so data wrapped the old way still decrypts.

Verify the handshake

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

On the JVM side, -Djavax.net.debug=ssl:handshake logs the key share groups offered and selected. More in How to check if a server uses post-quantum TLS.

FAQ

Which JDK supports post-quantum TLS?

JDK 27 (JEP 527) adds X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024 to TLS 1.3, with X25519MLKEM768 first in the default list. JDK 24 added ML-KEM itself (JEP 496) but not hybrid TLS.

How do I set named groups in Java?

Globally with -Djdk.tls.namedGroups=X25519MLKEM768,x25519,secp256r1,secp384r1, or per socket with SSLParameters.setNamedGroups().

Sources