Re-raise SSLErrors produced by TLS alerts as HandshakeErrors.#201
Open
sasozivanovic wants to merge 1 commit intopython-trio:masterfrom
Open
Re-raise SSLErrors produced by TLS alerts as HandshakeErrors.#201sasozivanovic wants to merge 1 commit intopython-trio:masterfrom
SSLErrors produced by TLS alerts as HandshakeErrors.#201sasozivanovic wants to merge 1 commit intopython-trio:masterfrom
Conversation
This commit relies on the bugfix proposed in PR python-trio/trio#3413 to address issue python-trio#199. From the user's perspective, the issue was that a TLS client hanged after submitting an invalid (e.g. expired) client certificate. The trio bugfix makes sure that the server (in general, peer) sends out the TLS alert after catching a `ssl.CertificateError`. In this commit, we do two things. First, we intercept `ssl.SSLError`s created by the alerts when receiving data from the stream (`WebSocketConnection._reader_task`) and sending data to the stream (`WebSocketConnection._send`), and wrap them into a `HandshakeError`. Second, we catch and ignore these `HandshakeError`s in `WebSocketServer._handle_connection`, so that a certificate error does not crash the server. Here, I'm unsure whether we should ignore *all* SSL errors (currently, this is the case), or maybe only those generated by alerts, or only those having to do with certificates, and neither do I know how to compile a comprehensive list of the latter, if that is what should be done.
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.
This pull request relies on the bugfix proposed in PR python-trio/trio#3413 to address issue #199 — which means that it definitely should not be accepted until the fate of that PR is resolved! In fact, some of the new tests introduced here must fail until run against an updated Trio.
From the user's perspective, the issue was that a TLS client hanged after submitting an invalid (e.g. expired) client certificate.
The trio bugfix makes sure that the server (in general, peer) sends out the TLS alert after catching a
ssl.CertificateError. In this commit, we do two things.First, we intercept
ssl.SSLErrors created by the alerts when receiving data from the stream (WebSocketConnection._reader_task) and sending data to the stream (WebSocketConnection._send), and wrap them into aHandshakeError.Second, we catch and ignore these
HandshakeErrors inWebSocketServer._handle_connection, so that a certificate error does not crash the server. Here, I'm unsure whether we should ignore all SSL errors (currently, this is the case), or maybe only those generated by alerts, or only those having to do with certificates, and neither do I know how to compile a comprehensive list of the latter, if that is what should be done.