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 — Make it possible to notify the TrustManager of resumed sessions by chrisvest · Pull Request #14358 · netty/netty

Conversation

@chrisvest

@chrisvest chrisvest commented Sep 21, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Motivation:
Some trust manager implementations produce custom user principals and store them in the SSLSession. Resumed TLS sessions, however, don't always recover the stored contents. For instance, with TLSv1.3 stateless session resumption, our TLS implementations only store the peer certificate chain (or even just the leaf cert) in the session ticket. In such a case, the trust manager would like to be notified of the resumption, so that the peer principal can be recreated and stored in the session once again.

Modification:
Add a ResumableX509ExtendedTrustManager interface, with callbacks for resumed client and server sessions. Add infrastructure (the ResumptionController) to detect session resumption in an SSLEngine implementation agnostic way; if a TLS handshake completed without any calls to the TrustManager, then we've made a "stateless resumption" (hand-wave details) and should call the appropriate resume method. The JDK APIs don't provide a method to reliably discern if a session has been resumed, so we instead detect if the trust manager was called during the handshake. We do this by wrapping user-supplied trust managers that implement the ResumableX509ExtendedTrustManager interface. The wrapper will monitor calls to the trust manager and register the relevant SSLEngine in the controller — the engine is the object that the trust manager and the SslHandler both have access to, which reliably identifies the specific TLS session. Before finished the handshake, the SslHandler queries the ResumptionController to see if the trust manager has already been called, or if it needs to be notified of resumption. Since it's possible that the peer certificates have expired since the initial session, the trust manager gets another change to throw CertificateException.

Result:
Handlers that expect to find user principals in the authenticated SSLSessions no longer find empty sessions, provided they use a trust manager that correctly implements ResumableX509ExtendedTrustManager.

This is a draft to gage if the general approach is sane. There's still a few things that need to be done:

  • Javadocs.
  • Tests where the resume* methods throw CertificateException.
  • Tests for different transports.
  • Tests that use TCP FastOpen.
  • Tests that use startTls.

Sorry, something went wrong.

Uh oh!

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

All reactions
@chrisvest
chrisvest requested a review from normanmaurer September 21, 2024 16:26
@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch 2 times, most recently from 7265063 to 0321af9 Compare September 21, 2024 16:30
chrisvest
chrisvest commented Sep 21, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch 2 times, most recently from 0e7cd81 to 46c8336 Compare September 21, 2024 17:57
github-advanced-security[bot]
github-advanced-security AI found potential problems Sep 21, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/JdkSslClientContext.java Fixed

Uh oh!

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

chrisvest
chrisvest commented Sep 21, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

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

@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch 3 times, most recently from cd3b1fb to 44e1c7d Compare September 22, 2024 01:05
@chrisvest

chrisvest commented Sep 23, 2024

Copy link
Copy Markdown
Member Author

Looks like Conscrypt on Windows is broken somehow.

All reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer
normanmaurer requested changes Sep 23, 2024
View reviewed changes

@normanmaurer normanmaurer 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.

Great idea!

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

chrisvest
chrisvest commented Sep 23, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

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

@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch 3 times, most recently from 5cfbf40 to 6343606 Compare September 23, 2024 22:01
@chrisvest chrisvest mentioned this pull request Sep 24, 2024
Fix OpenSslClientSessionCache remove #14366
Merged
@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch from fd077a9 to ec30834 Compare September 24, 2024 04:04
normanmaurer
normanmaurer requested changes Sep 24, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

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

normanmaurer
normanmaurer reviewed Sep 24, 2024
View reviewed changes
Comment thread transport/src/test/java/io/netty/bootstrap/BootstrapTest.java Resolved

Uh oh!

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

@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch 2 times, most recently from 0200c43 to bff04aa Compare September 24, 2024 23:32
@chrisvest
chrisvest marked this pull request as ready for review September 24, 2024 23:33
normanmaurer
normanmaurer reviewed Sep 25, 2024
View reviewed changes
Comment thread common/src/main/java/io/netty/util/concurrent/DefaultPromise.java Resolved

Uh oh!

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

normanmaurer
normanmaurer approved these changes Sep 25, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

chrisvest added 4 commits September 25, 2024 10:50
@chrisvest
Make it possible to notify the TrustManager of resumed sessions
6e68fe7
Motivation:
Some trust manager implementations produce custom user principals and store them in the SSLSession.
Resumed TLS sessions, however, don't always recover the stored contents.
For instance, with TLSv1.3 stateless session resumption, our TLS implementations only store the peer certificate chain (or even just the leaf cert) in the session ticket.
In such a case, the trust manager would like to be notified of the resumption, so that the peer principal can be recreated and stored in the session once again.

Modification:
Add a `ResumableX509ExtendedTrustManager` interface, with callbacks for resumed client and server sessions.
Add infrastructure (the `ResumptionController`) to detect session resumption in an SSLEngine implementation agnostic way; if a TLS handshake completed without any calls to the TrustManager, then we've made a "stateless resumption" (hand-wave details) and should call the appropriate resume method.
The JDK APIs don't provide a method to reliably discern if a session has been resumed, so we instead detect if the trust manager was called during the handshake.
We do this by wrapping user-supplied trust managers that implement the `ResumableX509ExtendedTrustManager` interface.
The wrapper will monitor calls to the trust manager and register the relevant `SSLEngine` in the controller — the engine is the object that the trust manager and the `SslHandler` both have access to, which reliably identifies the specific TLS session.
Before finished the handshake, the `SslHandler` queries the `ResumptionController` to see if the trust manager has already been called, or if it needs to be notified of resumption.
Since it's possible that the peer certificates have expired since the initial session, the trust manager gets another change to throw CertificateException.

Result:
Handlers that expect to find user principals in the authenticated SSLSessions no longer find empty sessions, provided they use a trust manager that correctly implements ResumableX509ExtendedTrustManager.
@chrisvest
Test debugging
09a3811
@chrisvest
Test debugging
f20b728
@chrisvest
Hide the ResumptionController from the public API
03fc08d
@chrisvest
Only run the original SocketSslSessionReuseTest.testSslSessionReuse o…
d1f1d23
…n the JDK SslProvider, like it used to
chrisvest
chrisvest commented Sep 26, 2024
View reviewed changes
Comment thread common/src/main/java/io/netty/util/concurrent/DefaultPromise.java Resolved

Uh oh!

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

@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch from 7b789aa to c1b375f Compare September 26, 2024 04:36
@chrisvest
Attempt to catch the StacklessClosedChannelException in SocketSslSess…
81aec45
…ionReuseTest.testSslSessionTrustManagerResumption
@chrisvest
chrisvest force-pushed the 4.1-resumable-tm branch from c1b375f to 81aec45 Compare September 26, 2024 04:38
normanmaurer
normanmaurer reviewed Sep 26, 2024
View reviewed changes
Comment thread common/src/main/java/io/netty/util/concurrent/DefaultPromise.java Resolved

Uh oh!

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

normanmaurer
normanmaurer requested changes Sep 26, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

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

Comment thread handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java Resolved

Uh oh!

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

Comment thread handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java Resolved

Uh oh!

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

Comment thread testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java Resolved

Uh oh!

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

chrisvest added 4 commits September 26, 2024 07:50
@chrisvest
Attempt to fix the OIO flakiness in SocketSslSessionReuseTest.testSsl…
7535e1b
…SessionTrustManagerResumption
@chrisvest
Address review comments
e525cbf
@chrisvest
Wrap an UnsupportedOperationException in CertificateException when ca…
72599ad
…lling unsupported methods in ResumptionController wrapping trust manager
@chrisvest
Remove test for TLSv1.3 because it might not be supported by all prov…
14f77c9
…iders
normanmaurer
normanmaurer requested changes Sep 26, 2024
View reviewed changes

@normanmaurer normanmaurer 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.

Almost there...

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread common/src/main/java/io/netty/util/concurrent/DefaultPromise.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

@chrisvest
Address more review comments
6ea0554
normanmaurer
normanmaurer reviewed Sep 26, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java Resolved

Uh oh!

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

@chrisvest
Preserve nulls in the certificate array
52cb631
normanmaurer
normanmaurer approved these changes Sep 26, 2024
View reviewed changes
@normanmaurer

normanmaurer commented Sep 26, 2024

Copy link
Copy Markdown
Member

Great work... Ship it!

All reactions

Sorry, something went wrong.

Uh oh!

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

@chrisvest
Fix buffer leaks in SSLEngineTest
ac285f8
@chrisvest chrisvest added this to the 4.1.114.Final milestone Sep 26, 2024
@chrisvest

chrisvest commented Sep 26, 2024

Copy link
Copy Markdown
Member Author

The Java 11 Graal build failure is caused by #14375.

The Java 11 BoringSSL build fails with an OOME in the HTTP/2 module at io.netty.handler.codec.http2.HpackDynamicTable.setCapacity(HpackDynamicTable.java:182), and I'm not immediately convinced it's related to these changes.

All reactions

Sorry, something went wrong.

Uh oh!

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

@chrisvest
chrisvest merged commit 3f66dd2 into netty:4.1 Sep 27, 2024
@chrisvest
chrisvest deleted the 4.1-resumable-tm branch September 27, 2024 02:33
@chrisvest

chrisvest commented Sep 27, 2024

Copy link
Copy Markdown
Member Author

Will do the forward merge tomorrow

All reactions

Sorry, something went wrong.

Uh oh!

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

chrisvest added a commit that referenced this pull request Sep 27, 2024
@chrisvest
Make it possible to notify the TrustManager of resumed sessions (#14358)
85f1335
@chrisvest chrisvest mentioned this pull request Sep 28, 2024
Make it possible to notify the TrustManager of resumed sessions #14378
Merged
chrisvest added a commit to chrisvest/netty that referenced this pull request Oct 18, 2024
@chrisvest
Make it possible to notify the TrustManager of resumed sessions (nett…
7a84470
…y#14358)
chrisvest added a commit that referenced this pull request Oct 23, 2024
@chrisvest
Make it possible to notify the TrustManager of resumed sessions (#14378)
c73ed93
Motivation:
Some trust manager implementations produce custom user principals and
store them in the SSLSession. Resumed TLS sessions, however, don't
always recover the stored contents. For instance, with TLSv1.3 stateless
session resumption, our TLS implementations only store the peer
certificate chain (or even just the leaf cert) in the session ticket. In
such a case, the trust manager would like to be notified of the
resumption, so that the peer principal can be recreated and stored in
the session once again.

Modification:
Add a ResumableX509ExtendedTrustManager interface, with callbacks for
resumed client and server sessions. Add infrastructure (the
ResumptionController) to detect session resumption in an SSLEngine
implementation agnostic way; if a TLS handshake completed without any
calls to the TrustManager, then we've made a "stateless resumption"
(hand-wave details) and should call the appropriate resume method. The
JDK APIs don't provide a method to reliably discern if a session has
been resumed, so we instead detect if the trust manager was called
during the handshake. We do this by wrapping user-supplied trust
managers that implement the ResumableX509ExtendedTrustManager interface.
The wrapper will monitor calls to the trust manager and register the
relevant SSLEngine in the controller — the engine is the object that the
trust manager and the SslHandler both have access to, which reliably
identifies the specific TLS session. Before finished the handshake, the
SslHandler queries the ResumptionController to see if the trust manager
has already been called, or if it needs to be notified of resumption.
Since it's possible that the peer certificates have expired since the
initial session, the trust manager gets another change to throw
CertificateException.

Result:
Handlers that expect to find user principals in the authenticated
SSLSessions no longer find empty sessions, provided they use a trust
manager that correctly implements ResumableX509ExtendedTrustManager.

This is a forward port of #14358,
#14404, and
#14411
This was referenced Sep 14, 2026
Http2: Reserve promised stream for PUSH_PROMISE after local RST_STREAM #17471
Closed
cache failure 1233e4a5 #17565
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.114.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@chrisvest @normanmaurer @github-advanced-security
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.