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 — Fix SSL session resumption with ClientAuth.OPTIONAL and add tests with session tickets by chrisvest · Pull Request #14404 · netty/netty

Conversation

@chrisvest

@chrisvest chrisvest commented Oct 17, 2024

Copy link
Copy Markdown
Member

Motivation:
If TLS is OPTIONAL then there won't always be a verified peer.
This means there will be no calls on the server TrustManager to check if the client is trusted.
That makes it look like a resumed session to the resumption controller.
But there won't be any verified peer on the session, and trying to get the peer certificates will throw an exception.

It's also a valid configuration to enable session tickets with TLSv1.2, and doing so makes a meaningful change to the SSLEngine behavior that we need to test for.

Modification:

  • Collect the OpenSSL parameterization code for SSLEngineTest.
  • Add tickets being enabled or not as a parameter.
  • Fix a test that did not anticipate the session ticket behavior.
  • Make the ResumptionController consider if the engine is in client mode, or if it requires client authentication, and only propagate SSLPeerUnverifiedException if so.
  • Make the ResumptionController swallow the SSLPeerUnverifiedException when client auth is OPTIONAL or NONE.
  • Add a test for this scenario.

Result:
We now have test coverage with TLSv1.2 session tickets.
The ResumableX509ExtendedTrustManager interface can now be used together with ClientAuth.OPTIONAL.

Sorry, something went wrong.

Uh oh!

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

All reactions
chrisvest added 3 commits October 17, 2024 15:41
@chrisvest
SSLEngineTest should parameterize over session ticket enablement
6afcc70
Motivation:
It's a valid configuration to enable session tickets with TLSv1.2, and doing so makes a meaningful change to the SSLEngine behavior that we need to test for.

Modification:
- Collect the OpenSSL parameterization code for SSLEngineTest.
- Add tickets being enabled or not as a parameter.
- Fix a test that did not anticipate the session ticket behavior.

Result:
We now have test coverage with TLSv1.2 session tickets.
@chrisvest
Support OPTIONAL SSL in the ResumptionController
7eb599c
Motivation:
If TLS is `OPTIONAL` then there won't always be a verified peer.
This means there will be no calls on the server `TrustManager` to check if the client is trusted.
That makes it look like a resumed session to the resumption controller.
But there won't be any verified peer on the session, and trying to get the peer certificates will throw an exception.

Modification:
- Make the `ResumptionController` consider if the engine is in client mode, or if it requires client authentication, and only propagate `SSLPeerUnverifiedException` if so.
- Make the `ResumptionController` swallow the `SSLPeerUnverifiedException` when client auth is OPTIONAL or NONE.
- Add a test for this scenario.

Result:
The `ResumableX509ExtendedTrustManager` interface can now be used together with `ClientAuth.OPTIONAL`.
@chrisvest
Checkstyle fixes
bc04cbf
@chrisvest
chrisvest requested a review from normanmaurer October 17, 2024 23:36
@chrisvest
SSLEngineTest fixes
e06c9c9
@chrisvest chrisvest added this to the 4.1.115.Final milestone Oct 18, 2024
@chrisvest
chrisvest force-pushed the 4.1-more-ssl-resume branch 4 times, most recently from 3c6b8bf to 12d973b Compare October 18, 2024 17:11
@chrisvest
Trace where executor shutdown occurred
4ce9964
@chrisvest
chrisvest force-pushed the 4.1-more-ssl-resume branch from 12d973b to 4ce9964 Compare October 18, 2024 17:16
chrisvest added 2 commits October 18, 2024 11:48
@chrisvest
Only test tickets with BoringSSL
4ac853c
@chrisvest
Revert "Trace where executor shutdown occurred"
1871be4
This reverts commit 4ce9964.
@chrisvest

chrisvest commented Oct 18, 2024

Copy link
Copy Markdown
Member Author

The extra testing makes the builds slower, particularly the BoringSSL builds, but that should be more than compensated for by #14405

All reactions

Sorry, something went wrong.

Uh oh!

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

Scottmitch
Scottmitch reviewed Oct 21, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/ResumptionController.java

SSLSession session = engine.getSession();
boolean valid = session.isValid();
if (valid && (engine.getUseClientMode() || engine.getNeedClientAuth() || engine.getWantClientAuth()) &&

@Scottmitch Scottmitch Oct 21, 2024

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.

can you add a comment clarifying the goal of this conditional?

getUseClientMode -> I assume this is to cover the case of "always do this on the client"

getNeedClientAuth || getWantClientAuth -> isn't the default treated by some engines as "want"? for example iirc openssl flavors will have the server request the client's certificate but if they don't return one it will succeed. so I'm just trying to understand if client/server need to be consistent and if not, why.

Sorry, something went wrong.

Uh oh!

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

All reactions

@chrisvest chrisvest Oct 21, 2024

Copy link
Copy Markdown
Member 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.

@Scottmitch I've added comments explaining the logic. Please take a look.

Sorry, something went wrong.

Uh oh!

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

All reactions
@chrisvest
Add comments on the ClientAuth.OPTIONAL handling
c31c29e
Scottmitch
Scottmitch approved these changes Oct 21, 2024
View reviewed changes
@chrisvest
chrisvest merged commit dc356e8 into netty:4.1 Oct 22, 2024
@chrisvest
chrisvest deleted the 4.1-more-ssl-resume branch October 22, 2024 20:09
chrisvest added a commit that referenced this pull request Oct 22, 2024
@chrisvest
Fix SSL session resumption with ClientAuth.OPTIONAL and add tests wit…
3bec5c6
…h session tickets (#14404)

Motivation:
If TLS is `OPTIONAL` then there won't always be a verified peer.
This means there will be no calls on the server `TrustManager` to check
if the client is trusted.
That makes it look like a resumed session to the resumption controller.
But there won't be any verified peer on the session, and trying to get
the peer certificates will throw an exception.

It's also a valid configuration to enable session tickets with TLSv1.2,
and doing so makes a meaningful change to the `SSLEngine` behavior that
we need to test for.

Modification:
- Collect the OpenSSL parameterization code for `SSLEngineTest`.
- Add tickets being enabled or not as a parameter.
- Fix a test that did not anticipate the session ticket behavior.
- Make the `ResumptionController` consider if the engine is in client
mode, or if it requires client authentication, and only propagate
`SSLPeerUnverifiedException` if so.
- Make the `ResumptionController` swallow the
`SSLPeerUnverifiedException` when client auth is OPTIONAL or NONE.
- Add a test for this scenario.

Result:
We now have test coverage with TLSv1.2 session tickets.
The `ResumableX509ExtendedTrustManager` interface can now be used
together with `ClientAuth.OPTIONAL`.
chrisvest added a commit to chrisvest/netty that referenced this pull request Oct 22, 2024
@chrisvest
Fix SSL session resumption with ClientAuth.OPTIONAL and add tests wit…
b26c521
…h session tickets (netty#14404)

Motivation:
If TLS is `OPTIONAL` then there won't always be a verified peer.
This means there will be no calls on the server `TrustManager` to check
if the client is trusted.
That makes it look like a resumed session to the resumption controller.
But there won't be any verified peer on the session, and trying to get
the peer certificates will throw an exception.

It's also a valid configuration to enable session tickets with TLSv1.2,
and doing so makes a meaningful change to the `SSLEngine` behavior that
we need to test for.

Modification:
- Collect the OpenSSL parameterization code for `SSLEngineTest`.
- Add tickets being enabled or not as a parameter.
- Fix a test that did not anticipate the session ticket behavior.
- Make the `ResumptionController` consider if the engine is in client
mode, or if it requires client authentication, and only propagate
`SSLPeerUnverifiedException` if so.
- Make the `ResumptionController` swallow the
`SSLPeerUnverifiedException` when client auth is OPTIONAL or NONE.
- Add a test for this scenario.

Result:
We now have test coverage with TLSv1.2 session tickets.
The `ResumableX509ExtendedTrustManager` interface can now be used
together with `ClientAuth.OPTIONAL`.
@chrisvest chrisvest mentioned this pull request Oct 22, 2024
Make it possible to notify the TrustManager of resumed sessions #14378
Merged
normanmaurer
normanmaurer reviewed Oct 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.

Late LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
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 left review comments
@Scottmitch Scottmitch Scottmitch 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.115.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 @Scottmitch
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.