Repository navigation
Conversation
Motivation: A hybrid ML-KEM key exchange for TLS 1.3 protects recorded traffic between nodes against later decryption by a quantum computer. The TLS providers of Pekko Remote had no way to choose the named groups of the key exchange, so a node could not prefer or require ML-KEM, and there was no guidance for Java runtimes whose TLS implementation does not support the hybrid groups. Modification: - Add a named-groups setting to the Artery ConfigSSLEngineProvider and RotatingKeysSSLEngineProvider and to the classic ConfigSSLEngineProvider. It is applied with SSLParameters.setNamedGroups, which is looked up with a MethodHandle because it needs JDK 20. A node with the setting does not start on earlier versions. - Document ML-KEM key exchange for Artery and classic remoting, with tested SSLEngineProvider examples for Bouncy Castle and Conscrypt in Scala and Java. Bouncy Castle and Conscrypt are test dependencies of docs only. Result: Nodes can prefer or require an ML-KEM key exchange by configuration on Java runtimes that support it, and by copying a documented example on others. Tests: - remote NamedGroupsSpec, ClassicRemotingWithNamedGroupsSpec, TlsTcpWithNamedGroupsSpec, TlsTcpWithRotatingKeysSSLEngineAndNamedGroupsSpec: passed on JDK 17 (11 passed, 21 pending) and JDK 25 (29 passed, 3 pending) - docs MlKemTlsDocSpec and MlKemTlsDocTest: 41 passed on JDK 17 - headerCheckAll, javafmtCheckAll, scalafmt, remote/mimaReportBinaryIssues, docs/paradox: passed References: None - follows apache/pekko-http#2040
| case Some(handle) => | ||
| val params = engine.getSSLParameters | ||
| handle.invokeWithArguments(params, namedGroups.toArray) | ||
| engine.setSSLParameters(params) |
There was a problem hiding this comment.
Policy enforcement depends on the active JSSE provider. The MethodHandle check proves the JDK setter exists, not that the engine obtained from SSLContext.getInstance honors it. The JSSE API explicitly allows providers to ignore this setting. Please either limit the documented requirement guarantee to providers that enforce named groups (and clearly distinguish this from the pre-JDK-20 startup check), or add a reliable fail-closed provider check if the setting is meant to enforce policy universally. Reading configured parameters back is not a negotiated-group assertion.
There was a problem hiding this comment.
Fixed in 61f9506 by scoping the guarantee, with no behaviour change. The docs now say the list is passed to the TLS implementation with SSLParameters.setNamedGroups and that the guarantee is what that implementation does with it; the prefer/require description is stated for SunJSSE, the provider these classes use unless another is registered ahead of it. Two bullets were added: the pre-JDK-20 startup check is only about the Java API, and a JSSE provider may ignore the setting, so a different registered provider has to be checked with a classical-only peer before relying on it to require ML-KEM. reference.conf and the NamedGroupsSupport scaladoc say the same. "Require" stays tied to protocol = "TLSv1.3". The pre-JDK-20 error and the empty-list path are unchanged. No test added for this one: the existing NamedGroupsSpec cases that back the SunJSSE claim are the handshake ones (ML-KEM-only peers connect, a classical-only peer is refused in both directions), not the parameter readback.
| It gives you two policies: | ||
|
|
||
| * **Prefer ML-KEM.** List the ML-KEM group first and classical groups after it. ML-KEM is used whenever the peer | ||
| supports it, and a peer without ML-KEM can still connect with a classical key exchange. |
There was a problem hiding this comment.
Please make this a preference, not a negotiation guarantee. RFC 9846 §§4.3.7–4.3.8 distinguish supported groups from the actual key shares offered. SunJSSE can use an acceptable offered share without requesting a share for another mutually supported group. A peer supporting ML-KEM is therefore not sufficient on its own. Adjust the rolling-upgrade text too, and keep the documented BCJSSE server-order behavior scoped to BCJSSE.
There was a problem hiding this comment.
Fixed in 61f9506. "Prefer" is now described as a preference and not a guarantee, with a bullet explaining that the connecting node sends key shares for the first groups of its list and the accepting node may use one of them even when both support a group it lists earlier (RFC 9846 section 4.3.8). The opening paragraph says nodes offer ML-KEM to each other, and the rolling-upgrade steps no longer claim that preferring nodes use ML-KEM with each other; only the require step is stated as a guarantee. The setUseNamedGroupsOrder bullet now says the behaviour and the call are specific to Bouncy Castle. In the tests, the cases that claim which group won already use the negotiated group reported by a Conscrypt peer (MlKemTlsDocSpec: X25519MLKEM768 with a preferring BC node, and x25519 when the accepting BC node lists it first); the SunJSSE cases only assert success or failure of the handshake.
| Copy this class into your project: | ||
|
|
||
| Scala | ||
| : @@snip [MlKemTls.scala](/docs/src/test/scala/docs/remoting/MlKemTls.scala) { #conscrypt } |
There was a problem hiding this comment.
The Scala example is not standalone as rendered. The #conscrypt fragment in MlKemTls.scala includes the Conscrypt import but not Config, Files, KeyStore, or the javax SSL types; those shared imports appear only in #bouncy-castle. The whole-file test sees them and cannot catch this. Please make the rendered fragments self-contained, including the classic wrapper imports, and show the actual Scala/Java Conscrypt provider wrappers or link to their complete source. A compile check of the extracted examples would cover this.
There was a problem hiding this comment.
Fixed in 61f9506. MlKemTls.scala is split into one file per class (BouncyCastleEngines, ConscryptEngines, and the Artery and classic provider for each), and each file is one snippet that starts at its own imports, so the rendered fragment is the whole compilation unit that the build compiles. The Conscrypt provider wrappers are now rendered too, Scala and Java: for Artery in remote-security.md and for classic remoting in remoting.md, next to the Bouncy Castle ones. MlKemTlsDocSpec runs against these classes (41 passed on JDK 17) and docs/paradox passes.
|
|
||
| // SSLParameters.getNamedGroups was added in JDK 20, like setNamedGroups | ||
| def namedGroupsOf(params: SSLParameters): List[String] = | ||
| classOf[SSLParameters].getMethod("getNamedGroups").invoke(params).asInstanceOf[Array[String]].toList |
There was a problem hiding this comment.
Treat missing provider capability separately from a missing Java API. getNamedGroups() is nullable per the JSSE API. Here .toList can throw when probing getSupportedSSLParameters, before runtimeSupportsMlKem can skip the provider-specific cases. Please make that probe null-safe and keep the explicit positive handshake assertion on providers expected to support the selected group.
There was a problem hiding this comment.
Fixed in 61f9506. namedGroupsOf in NamedGroupsSpec now maps a null getNamedGroups() to an empty list, so a provider that does not tell its groups makes runtimeSupportsMlKem false and the ML-KEM cases pending, without throwing. The positive assertion is kept: where the runtime lists X25519MLKEM768, peers that only allow that group must complete the handshake. Re-ran NamedGroupsSpec on JDK 17 (6 passed, 21 pending as they need JDK 20+); the JDK 20+ path of this probe is left to CI.
| } | ||
|
|
||
| "negotiate X25519MLKEM768 with a peer that supports it" in { | ||
| negotiatedGroup(conscrypt(), bouncyCastle(PreferMlKemGroups)) should ===("x25519mlkem768") |
There was a problem hiding this comment.
Keep Java-only BC coverage runnable without Conscrypt’s native library. These BC negotiation checks use a Conscrypt peer, and the Conscrypt block also loads it unconditionally. The 2.10.0 provider exposes isAvailable() because native support is platform-dependent. Please isolate or capability-gate all Conscrypt-dependent cases, including these mixed-provider checks, while still requiring them on supported CI targets and leaving BC-only cases active.
There was a problem hiding this comment.
Fixed in 61f9506. Every case in MlKemTlsDocSpec that needs Conscrypt, including the two Bouncy Castle cases that use a Conscrypt peer to read the negotiated group, now starts with requireConscrypt(). It checks Conscrypt.isAvailable: on a platform that conscrypt-openjdk-uber has no native library for the case is cancelled, and on the platforms it has one for (Linux and macOS on x86_64 and aarch64, Windows on x86_64) the case fails, so CI still requires them. The Bouncy Castle only cases, including delivery over Artery and classic remoting, and the Java test do not touch Conscrypt and stay active. Re-ran the spec on JDK 17 on macOS aarch64: 41 passed, none cancelled.
Follow-up checklist for the next revisionReview scope:
This review checked the source and existing test oracles; it did not rerun the PR’s test suite. No default, public API, or runtime dependency change is needed merely to resolve these review points. |
Motivation: Review of the named-groups setting and the ML-KEM examples found that the docs promised more than the setting can guarantee, that the rendered Scala examples did not carry their own imports, and that tests assumed provider capabilities that are optional. Modification: - Docs: named-groups is enforced by the JSSE provider, which may ignore it; the pre-JDK-20 check is only about the Java API. "Prefer" is a preference that depends on the key shares of the connecting node, and the rolling upgrade text no longer claims ML-KEM between preferring nodes. The setUseNamedGroupsOrder behaviour is scoped to Bouncy Castle. - Split the Scala examples into one file per class, each with its own imports, and render the Conscrypt provider wrappers for Artery and classic remoting in Scala and Java. - NamedGroupsSpec: treat a null getNamedGroups as no capability. - MlKemTlsDocSpec: gate every case that needs Conscrypt on Conscrypt.isAvailable. They are cancelled where the artifact has no native library and fail where it has one and cannot load it. Bouncy Castle only cases stay active. Result: The documented guarantees match what the providers enforce, and each rendered example compiles on its own. Tests: - remote NamedGroupsSpec: passed on JDK 17 (6 passed, 21 pending) - docs MlKemTlsDocSpec and MlKemTlsDocTest: 41 passed on JDK 17 - docs/javafmtAll, scalafmt, headerCheckAll, docs/paradox: passed References: Refs apache#3843
Motivation
A hybrid ML-KEM key exchange for TLS 1.3 (such as
X25519MLKEM768) protects recorded traffic between nodes against later decryption by a quantum computer. The TLS providers of Pekko Remote had no way to choose the named groups of the key exchange, so a node could not prefer or require ML-KEM. There was also no guidance for Java runtimes whose TLS implementation does not support the hybrid groups, which includes many JDK 17 builds.Modification
named-groupssetting (default[], the defaults of the Java runtime) for:pekko.remote.artery.ssl.config-ssl-enginepekko.remote.artery.ssl.rotating-keys-enginepekko.remote.classic.netty.ssl.securitySSLParameters.setNamedGroups. That method needs JDK 20, so it is looked up with aMethodHandle(NamedGroupsSupport, internal). A node with the setting does not start on earlier versions, so it cannot silently run with other groups.remote-security.md(Artery) andremoting.md(classic): the prefer and require policies, rolling upgrades, and the pitfalls of each option.SSLEngineProviderexamples for Bouncy Castle and Conscrypt, in Scala and Java, for Artery and classic remoting. They live in thedocstest sources and run as tests.bcprov,bctls, MIT-style licence) and Conscrypt 2.10.0 (Apache 2.0) are test dependencies ofdocsonly. Their versions are shown in the docs through Paradox properties.The deprecation status of classic remoting is unchanged. No runtime dependency or default changes.
Result
Nodes can prefer or require an ML-KEM key exchange by configuration on Java runtimes that support it (JDK 27, and update releases of some earlier versions), and by copying a documented and tested example on others, from JDK 17.
Tests
remote/Test/testOnlyNamedGroupsSpec,ClassicRemotingWithNamedGroupsSpec,TlsTcpWithNamedGroupsSpec,TlsTcpWithRotatingKeysSSLEngineAndNamedGroupsSpec:setNamedGroups); covers the failure to start withnamed-groupssetX25519MLKEM768): 29 passed, 3 pending; covers group order, common and disjoint groups, unsupported names, and ML-KEM only, preferred and required, for all three providersdocs/Test/testOnly docs.remoting.MlKemTlsDocSpec jdocs.remoting.MlKemTlsDocTest: 41 passed on JDK 17. The spec runs the same cases against the Scala and the Java examples: each ML-KEM group, the negotiated group read from a Conscrypt peer, the accepting side's order, refusal of peers without ML-KEM, interoperation with the JDK's provider, and message delivery over Artery and classic remoting.remote/headerCheckAll,docs/headerCheckAll,docs/javafmtCheckAll,scalafmt,remote/mimaReportBinaryIssues,docs/paradox,git diff --check: passed.RemoteConfigSpec(compiled only),sbt validatePullRequest, the Scala 3 build and other modules' tests. Left to CI.References
None - follows apache/pekko-http#2040