Skip to content

Enable post-quantum TLS on a Java server

Upgrade to JDK 25.0.5+ or 27 to get X25519MLKEM768. The JDK supports it but does not prefer it; a proxy in front can.

Tested on Java 27.0.1 Lab run 2026-12-05 15 min Requires JDK 25.0.5+ or JDK 27+

The fix

Upgrade the JDK. JDK 25.0.5 and newer 25 updates, and JDK 27, turn on the X25519MLKEM768 hybrid by default in the JDK's own TLS (JSSE). JDK 21 and JDK 26 do not have it.

If you set jdk.tls.namedGroups, keep the hybrid in the list:

JVM options
-Djdk.tls.namedGroups=X25519MLKEM768,x25519,secp256r1,secp384r1

Or remove the property: the default list already starts with X25519MLKEM768.

What this does not fix: a Java server uses post-quantum only when the client sends a post-quantum key share first. Browsers do. A client that leads with X25519 gets X25519, even if it also supports the hybrid. The order of jdk.tls.namedGroups does not change this. If you need the server to prefer post-quantum, terminate TLS in a proxy in front of Java, for example Nginx, and keep Java behind it.

Check your JDK first

java -version
Official eclipse-temurin image JDK X25519MLKEM768 by default?
eclipse-temurin:21 21.0.13.1 No, and naming it in jdk.tls.namedGroups does nothing
eclipse-temurin:25.0.4.1_1 25.0.4.1 No
eclipse-temurin:25.0.5_8 25.0.5 Yes
eclipse-temurin:25 25.0.5.1 Yes
eclipse-temurin:26 26.0.2.1 No
eclipse-temurin:27 27.0.1.1 Yes

Checked by running each image on 2026-12-06 (default groups from SSLParameters.getNamedGroups(), plus a TLS connection). JDK 27 also accepts SecP256r1MLKEM768 when you add it to jdk.tls.namedGroups; it is not on by default.

What the common configs actually do

Tested in Docker against five client offers, including the exact one browsers send, with a plain JDK HttpsServer. "Preferred" means the server asks for post-quantum even when the client led with a classical key share.

Config Post-quantum What browsers get
JDK 27 or 25.0.5+, no jdk.tls.namedGroups (this fix) Supported, not preferred X25519MLKEM768
JDK 27, jdk.tls.namedGroups=X25519MLKEM768,x25519,… Supported, not preferred X25519MLKEM768
JDK 27, jdk.tls.namedGroups=x25519,X25519MLKEM768,… Supported, not preferred X25519MLKEM768
JDK 27, jdk.tls.namedGroups=x25519,secp256r1,secp384r1 (old hardening guides) Off X25519 (classical)
JDK 26, default Off X25519 (classical)
JDK 21, jdk.tls.namedGroups=X25519MLKEM768,… Off X25519 (classical)

"Supported, not preferred" looks the same in a browser today, but a client that leads with a classical key share gets classical encryption. Only a TLS endpoint that prefers post-quantum closes that gap.

JDK 21 starts without an error when the property names X25519MLKEM768. It just leaves the group out. Check with the command below; don't trust the config alone.

Verify

openssl s_client -connect example.com:443 -groups X25519MLKEM768 </dev/null 2>&1 | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768

Or rescan with PQ Scan: after the upgrade the Confidentiality axis should read PQ supported. It reads PQ preferred only once a proxy that prefers post-quantum terminates TLS.

Things that don't change

  • Your certificate and keystore stay the same (post-quantum certificates are not available for public websites yet).
  • Clients without post-quantum support still connect with X25519 or P-256.
  • This applies to servers that use the JDK's own TLS. If a CDN, load balancer or reverse proxy terminates TLS in front of Java, visitors see its TLS, not the JDK's. Fix it there.

Ask your AI about this fix

Copy the recipe as Markdown, or open it in an assistant that can read the page.