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

> JDK 27 (JEP 527) enables X25519MLKEM768 by default in TLS 1.3. How to configure named groups, what to do on older JDKs, and ML-KEM via the KEM API.

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

JDK 27 (released September 2026) is the first JDK with hybrid post-quantum TLS built in. [JEP 527](https://openjdk.org/jeps/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.

## Which JDK, and is anything overriding the groups?

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

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

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

## 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](https://openjdk.org/jeps/496)) behind the generic `javax.crypto.KEM` API from JDK 21:

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

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

- [JEP 527: Post-Quantum Hybrid Key Exchange for TLS 1.3](https://openjdk.org/jeps/527)
- [inside.java: Post-Quantum Hybrid Key Exchange for TLS 1.3 (Feb 2026)](https://inside.java/2026/02/17/tls-post-quantum-hybrid-key-exchange/)
- [Oracle: Java 27 release (Sept 15, 2026)](https://www.oracle.com/news/announcement/oracle-releases-java-27-and-strengthens-post-quantum-cryptography-support-2026-09-15/)
- [JEP 496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism](https://openjdk.org/jeps/496)
