Make it possible to notify the TrustManager of resumed sessions#14358
Merged
Make it possible to notify the TrustManager of resumed sessions#14358
Conversation
7265063 to
0321af9
Compare
chrisvest
commented
Sep 21, 2024
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
0e7cd81 to
46c8336
Compare
chrisvest
commented
Sep 21, 2024
cd3b1fb to
44e1c7d
Compare
Member
Author
|
Looks like Conscrypt on Windows is broken somehow. |
normanmaurer
requested changes
Sep 23, 2024
handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
chrisvest
commented
Sep 23, 2024
5cfbf40 to
6343606
Compare
fd077a9 to
ec30834
Compare
normanmaurer
requested changes
Sep 24, 2024
handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumableX509ExtendedTrustManager.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
0200c43 to
bff04aa
Compare
common/src/main/java/io/netty/util/concurrent/DefaultPromise.java
Outdated
Show resolved
Hide resolved
normanmaurer
approved these changes
Sep 25, 2024
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
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.
Member
Author
|
@normanmaurer I think this is good to go, assuming the tests are no longer flaky. |
…n the JDK SslProvider, like it used to
chrisvest
commented
Sep 26, 2024
common/src/main/java/io/netty/util/concurrent/DefaultPromise.java
Outdated
Show resolved
Hide resolved
7b789aa to
c1b375f
Compare
…ionReuseTest.testSslSessionTrustManagerResumption
c1b375f to
81aec45
Compare
common/src/main/java/io/netty/util/concurrent/DefaultPromise.java
Outdated
Show resolved
Hide resolved
normanmaurer
requested changes
Sep 26, 2024
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java
Outdated
Show resolved
Hide resolved
…SessionTrustManagerResumption
…lling unsupported methods in ResumptionController wrapping trust manager
normanmaurer
requested changes
Sep 26, 2024
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
normanmaurer
approved these changes
Sep 26, 2024
Member
|
Great work... Ship it! |
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 |
Member
Author
|
Will do the forward merge tomorrow |
chrisvest
added a commit
that referenced
this pull request
Sep 27, 2024
chrisvest
added a commit
to chrisvest/netty
that referenced
this pull request
Oct 18, 2024
chrisvest
added a commit
that referenced
this pull request
Oct 23, 2024
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
ResumableX509ExtendedTrustManagerinterface, with callbacks for resumed client and server sessions. Add infrastructure (theResumptionController) 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 theResumableX509ExtendedTrustManagerinterface. The wrapper will monitor calls to the trust manager and register the relevantSSLEnginein the controller — the engine is the object that the trust manager and theSslHandlerboth have access to, which reliably identifies the specific TLS session. Before finished the handshake, theSslHandlerqueries theResumptionControllerto 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:
resume*methods throwCertificateException.