-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Make it possible to notify the TrustManager of resumed sessions #14358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7265063
to
0321af9
Compare
handler/src/main/java/io/netty/handler/ssl/ResumptionController.java
Outdated
Show resolved
Hide resolved
0e7cd81
to
46c8336
Compare
cd3b1fb
to
44e1c7d
Compare
Looks like Conscrypt on Windows is broken somehow. |
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!
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
5cfbf40
to
6343606
Compare
fd077a9
to
ec30834
Compare
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
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.
@normanmaurer I think this is good to go, assuming the tests are no longer flaky. |
…n the JDK SslProvider, like it used to
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
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
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...
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
Great work... Ship it! |
The Java 11 Graal build failure is caused by #14375. The Java 11 BoringSSL build fails with an OOME in the HTTP/2 module |
Will do the forward merge tomorrow |
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
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 (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 theResumableX509ExtendedTrustManager
interface. The wrapper will monitor calls to the trust manager and register the relevantSSLEngine
in the controller — the engine is the object that the trust manager and theSslHandler
both have access to, which reliably identifies the specific TLS session. Before finished the handshake, theSslHandler
queries theResumptionController
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:
resume*
methods throwCertificateException
.