fix: handle TLS 1.3 post-handshake auth errors in _loopback_for_cert_thread (closes #209)#824
Conversation
❌ 2 Tests Failed:
View the full list of 2 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
Documentation build overview
3 files changed± history/index.html± pkg/cheroot.server/index.html± pkg/cheroot.ssl.pyopenssl/index.html |
avinashkamat48-design
left a comment
There was a problem hiding this comment.
The new except ssl.SSLError branch does not actually preserve unexpected SSL errors because it is nested inside the existing outer with suppress(ssl.SSLError, OSError): block. Even when _assert_ssl_exc_contains(...) returns false and the code does
aise, that re-raised SSLError is immediately swallowed by the surrounding suppress, so behavior remains 'suppress every SSLError'. To make the filter meaningful, the selective ry/except needs to live outside the broad suppress or the outer suppress needs to stop including ssl.SSLError.
What
When a client uses the TLS 1.3
post_handshake_authextension and authentication fails, the server can receive an SSL error after the handshake is complete. This exception is currently unhandled in the_loopback_for_cert_threadfunction, causing a traceback that propagates to thecommunicatemethod and breaks request parsing.Fix
Wrap the
wrap_socketcall inside_loopback_for_cert_threadin an additional try/except block that catchesssl.SSLErrorexceptions specifically related to post-handshake authentication failures (e.g., decrypt errors, TLSv1 alert). The existingsuppresscontext manager continues to handle connection/OS errors. The new handler only suppresses known post-handshake TLS 1.3 errors and re-raises unexpected ones.Closes #209