GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add exportKeyingMaterial() to QuicSslEngine (RFC 5705 TLS exporter) by Dolfik1 · Pull Request #17111 · netty/netty

Conversation

@Dolfik1

@Dolfik1 Dolfik1 commented Jul 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Motivation:

There is currently no way to obtain exported keying material (RFC 5705,
also known as a TLS exporter) from a QUIC connection. Exported keying
material is useful for channel binding: an application can bind a proof
(e.g. a signature made with a client private key) to the underlying
QUIC connection, so the proof cannot be replayed on a different
connection.

Modifications:

  • Add QuicSslEngine.exportKeyingMaterial(String label, byte[] context,
    int length). The base implementation throws
    UnsupportedOperationException so existing sub-classes are not broken.
  • Implement it in QuicheQuicSslEngine on top of BoringSSLs
    SSL_export_keying_material via a new JNI binding.
  • Map a null context to use_context = 0 and an empty array to
    use_context = 1 with zero length. As QUIC always uses TLS 1.3, both
    produce the same keying material (unlike TLS 1.2 / RFC 5705); this is
    documented on the method.
  • Throw SSLException if the handshake did not complete yet or the
    connection is not available anymore.
  • Add tests that verify both peers derive identical keying material for
    the same label / context, that different labels and contexts produce
    different output, that an empty and null context produce the same
    output, that a zero length request returns an empty array, that a
    negative length is rejected and that exporting before the handshake
    completed throws.

Result:

Keying material can be exported from a QUIC connection, enabling
channel binding and similar use cases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timothyklim reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@Dolfik1 Dolfik1 changed the title Add exportKeyingMaterial to QUIC SSL engine Add exportKeyingMaterial() to QuicSslEngine (RFC 5705 TLS exporter) Jul 28, 2026
@Dolfik1
Dolfik1 force-pushed the tls-material-exporter branch from 2a4b1ab to 0a8b211 Compare July 28, 2026 15:57
@Dolfik1

Dolfik1 commented Jul 28, 2026

Copy link
Copy Markdown
Author

Updated the commit message to follow the commit message guidelines. Happy to address any feedback.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Aug 3, 2026

Copy link
Copy Markdown
Member

@Dolfik1 did you sign our icla yet ? https://netty.io/s/icla

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Dolfik1

Dolfik1 commented Aug 3, 2026

Copy link
Copy Markdown
Author

@Dolfik1 did you sign our icla yet ? https://netty.io/s/icla

Yes, I signed it before and signed it again to be sure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer reviewed Aug 4, 2026
View reviewed changes
Comment thread codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicSslEngine.java Outdated
* material.
*/
public byte[] exportKeyingMaterial(String label, byte @Nullable [] context, int length) throws SSLException {
throw new UnsupportedOperationException();

@normanmaurer normanmaurer Aug 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to just use return null as not supported. WDYT ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Dolfik1 Dolfik1 Aug 4, 2026

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exportKeyingMaterial method is intended for cryptographic purposes, so an explicit exception instead of null may be preferable to avoid possible errors in user code (fail-fast).

Looking at the implementation in QuicheQuicSslEngine, you can see that we always throw an SSLException if the underlying implementation returns null, so user code should already expect and handle exceptions.

Additionally, we currently always implement this method, so this exception can only be thrown if a new implementation of the class is added in the future or if this interface is implemented in user code.

If you disagree with my reasoning, let me know and I'll fix it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Aug 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@chrisvest chrisvest Aug 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing a length I think we could pass in the exportedKeyMaterial byte array as a parameter, and either return void and throw if not supported, or return a boolean indicated if EKM was exported.

That way we eliminate an OutOfMemoryError possibility from the (*env)->NewByteArray(env, length) call.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer normanmaurer added this to the 4.2.17.Final milestone Aug 4, 2026
normanmaurer
normanmaurer approved these changes Aug 4, 2026
View reviewed changes
@Dolfik1

Dolfik1 commented Aug 4, 2026

Copy link
Copy Markdown
Author

@normanmaurer One thought about this PR: this feature could be useful not only for QUIC connections but also for any TLS 1.2+ connections. We could mark this method as @UnstableApi and consider extracting it into a separate interface in the future, which could also be implemented by ReferenceCountedOpenSslEngine to support this functionality for OpenSSL engine. In this way we can even get rid of the UnsupportedOperationException in the future.

I wouldn't move this method into a separate interface now, since I'm not sure what the final API will look like.

What do you think about this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Aug 4, 2026
@chrisvest chrisvest modified the milestones: 4.2.17.Final, 4.2.18.Final Aug 4, 2026
@normanmaurer

normanmaurer commented Aug 7, 2026

Copy link
Copy Markdown
Member

@normanmaurer One thought about this PR: this feature could be useful not only for QUIC connections but also for any TLS 1.2+ connections. We could mark this method as @UnstableApi and consider extracting it into a separate interface in the future, which could also be implemented by ReferenceCountedOpenSslEngine to support this functionality for OpenSSL engine. In this way we can even get rid of the UnsupportedOperationException in the future.

I wouldn't move this method into a separate interface now, since I'm not sure what the final API will look like.

What do you think about this?

@Dolfik1 good question... We could for example create a new abstract class ExtendedSslEngine (not sure about the name), but the method there and drop it in the handler module. Then let our ReferenceCountedOpenSslEngine extend it and the same also for QuicSslEngine. That said we could also do it later if needed.

@chrisvest WDYT ?

chrisvest reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chrisvest
chrisvest reviewed Aug 11, 2026
View reviewed changes

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could define the method in a KeyMaterialExporter interface in netty-handler.
The QuicSslEngine could then implement this, or we could make only the QuicheQuicSslEngine implement it so support gated by an instanceof and cast. Although support could in principle depend on runtime factors rather than types.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicSslEngine.java Outdated
* material.
*/
public byte[] exportKeyingMaterial(String label, byte @Nullable [] context, int length) throws SSLException {
throw new UnsupportedOperationException();

@chrisvest chrisvest Aug 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing a length I think we could pass in the exportedKeyMaterial byte array as a parameter, and either return void and throw if not supported, or return a boolean indicated if EKM was exported.

That way we eliminate an OutOfMemoryError possibility from the (*env)->NewByteArray(env, length) call.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicSslEngine.java
ObjectUtil.checkPositiveOrZero(length, "length");

final byte[] keyingMaterial;
synchronized (this) {

@chrisvest chrisvest Aug 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the concurrency here problematic.

The event loop thread drives the TLS state machine indirectly through calls into quiche, while we at the same time expose this public methods that make calls on SSL*.

The other synchronized methods operate either on snapshot data extracted at handshake time from the event loop, or doesn't make use of SSL*.

This method can be called from outside of the event loop, and needs a live SSL* which is assumed to be a single-threaded object. I don't think that's a good idea, and that we instead somehow need to enforce that this method is called from within the event loop.

What I think we could do is to add an EventLoop field to QuicheQuicConnection, that we could assign in QuicheQuicChannel.attachQuicheConnection if we add an EventLoop parameter to it. For client channels, the ctx.eventLoop() can be passed right in, and for server child-channels we'd have to grab the chosen event loop instance first to pass in, and then use the same event loop for the register(channel) call later in QuicheQuicServerCodec.handleServer.

Maybe @normanmaurer has a different idea.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chrisvest chrisvest modified the milestones: 4.2.18.Final, 4.2.19.Final Sep 10, 2026
@normanmaurer normanmaurer modified the milestones: 4.2.19.Final, 4.2.20.Final Oct 14, 2026
@Dolfik1
Dolfik1 force-pushed the tls-material-exporter branch from 0a8b211 to 805aa52 Compare October 26, 2026 06:21
@Dolfik1

Dolfik1 commented Oct 26, 2026

Copy link
Copy Markdown
Author

@normanmaurer @chrisvest Sorry for the long silence. I was away for a few months. I am back now, and I made all the requested changes:

  • Moved the method to a new @UnstableApi KeyMaterialExporter interface in netty-handler. Only QuicheQuicSslEngine implements it, so QuicSslEngine does not change and the UnsupportedOperationException is gone.
  • The caller now supplies the output array, so the native code does not call NewByteArray.
  • QuicheQuicConnection now stores the EventLoop of the channel. A call from a different thread throws IllegalStateException.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@testlens-app

testlens-app Bot commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Failed Jobs without Test Failures

❌ Build PR / linux-x86_64-java11 build
❌ Build PR / linux-x86_64-java11-awslc build
❌ Build PR / linux-x86_64-java11-boringssl build
❌ Build PR / linux-x86_64-java11-boringssl-jdk8-tests build
❌ Build PR / linux-x86_64-java11-pooled build
❌ Build PR / linux-x86_64-java17 build
❌ Build PR / linux-x86_64-java21 build
❌ Build PR / linux-x86_64-java21-graal build
❌ Build PR / linux-x86_64-java24 build
❌ Build PR / linux-x86_64-java25 build
❌ Build PR / linux-x86_64-java26 build
❌ Verify native library loading on musl / build-jars-aarch64
❌ Verify native library loading on musl / build-jars-x86_64

Test Summary

Tip

Inspect all details with the TestLens CLI: testlens pr 17111

Build PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueETSocketHalfClosedTest > testAllDataReadClosure(TestInfo) 🚫 ❌ 1% 🟡

🏷️ Commit: 805aa52
▶️ Tests: 5035 executed
⚪️ Checks: 22/22 completed

Test Failures

KQueueETSocketHalfClosedTest > testAllDataReadClosure(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)
java.util.concurrent.TimeoutException: testAllDataReadClosure(org.junit.jupiter.api.TestInfo) timed out after 20000 milliseconds
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	Suppressed: java.lang.InterruptedException
		at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1040)
		at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1345)
		at java.base/java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:784)
		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:690)
		at io.netty.testsuite.transport.socket.SocketHalfClosedTest$16.run(SocketHalfClosedTest.java:684)
		at io.netty.testsuite.transport.socket.SocketHalfClosedTest$16.run(SocketHalfClosedTest.java:681)
		at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:681)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		... 2 more

Rerun Controls

Select tests to mute in this pull request:

  • KQueueETSocketHalfClosedTest > testAllDataReadClosure(TestInfo)

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest modified the milestones: 4.2.20.Final, 4.2.21.Final Nov 2, 2026
@nmatyushin @Dolfik1
Add KeyMaterialExporter and implement it for QUIC
13d5283
Motivation:

There is no way to get exported keying material (RFC 5705, also known as
a TLS exporter) from a QUIC connection. Applications use exported keying
material for channel binding. For example, a client can sign the
exported value with its private key. The signature is then bound to the
QUIC connection, and an attacker cannot replay it on a different
connection.

Modifications:

- Add the KeyMaterialExporter interface to netty-handler and mark it
  with @UnstableApi. Other SSLEngine implementations, for example
  ReferenceCountedOpenSslEngine, can implement it later. Applications
  use an instanceof check to find out if an engine supports it.
- Implement KeyMaterialExporter in QuicheQuicSslEngine on top of
  SSL_export_keying_material from BoringSSL, with a new JNI binding.
  QuicSslEngine does not change.
- The caller supplies the output array. Thus the native code does not
  allocate Java arrays. The native code also clears its temporary buffer
  before it frees it.
- Store the EventLoop of the channel in QuicheQuicConnection. The
  SSL object is not thread-safe, and the event loop drives it.
  Thus a call from a different thread throws IllegalStateException.
- Map a null context to use_context = 0. Map an empty array to
  use_context = 1 with zero length. QUIC always uses TLS 1.3, so both
  give the same keying material. The javadoc documents this.
- Throw SSLException if the handshake is not complete, or if the
  connection is closed.
- Add tests. The tests make sure that both peers get the same keying
  material for the same label and context. They make sure that a
  different label or context gives different output. They also make
  sure that an empty context and a null context give the same output,
  and that an empty output array is permitted. Other tests make sure
  that a call from a different thread and a call before the handshake
  throw.

Result:

Applications can export keying material from a QUIC connection. This
makes channel binding and similar use cases possible.
@Dolfik1
Dolfik1 force-pushed the tls-material-exporter branch from 805aa52 to 13d5283 Compare November 5, 2026 08:48
@Dolfik1

Dolfik1 commented Nov 5, 2026

Copy link
Copy Markdown
Author

@chrisvest I rebased the branch onto the latest 4.2. The earlier Linux failures came from the outdated SDKMAN installer checksum in the Dockerfiles, and #18135 on 4.2 fixed it. The macOS kqueue failure (KQueueETSocketHalfClosedTest timeout) looks like a flaky test, because this PR doesn't touch transport code. The new workflow runs are waiting for maintainer approval. Could you approve them, please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest modified the milestones: 4.2.21.Final, 4.2.22.Final Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest left review comments
@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged.

Projects

None yet

Milestone

4.2.22.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Dolfik1 @normanmaurer @chrisvest @nmatyushin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.