-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Issue7476 #7781
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
base: main
Are you sure you want to change the base?
Issue7476 #7781
Conversation
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.
LGTM
|
Shouldn't we handle the mitmproxy/mitmproxy/proxy/layers/tls.py Line 455 in a4d794c
|
|
Thank you for the review, @errorxyz! I don’t think close_notify should be handled within the send_data() context. This block (except (SSL.ZeroReturnError, SSL.SysCallError)) is meant to catch cases where the peer unexpectedly closes the connection or a transmission error occurs. Since send_data() is part of the active write phase, inserting a close_notify alert here would violate the TLS state machine — alerts must only be sent after the final successful SSL_write, as per RFC 8446. In TLS 1.3, it is valid for the peer not to send a close_notify. We detect that on the read side via SSL.ZeroReturnError, and the recent changes explicitly track this in self.peer_sent_close_notify. If no alert is received, we synthesize one during send_close() to maintain spec compliance. So, I think no additional handling is needed in send_data(). |
I can't seem to find this specified in the RFC. Can you please provide a reference? Also, as per section 6.1,
we should be immediately sending a close_notify for TLS < 1.3. |
f5924b4 to
6b1ea20
Compare
|
Yes, you're right, thanks @errorxyz ! Updated: we now handle close_notify on ZeroReturnError in the send_data function for TLS < 1.3. |
Description
Fix(tls): Send TLS close_notify .
Mitmproxy's TLS layer previously did not send a
close_notifyalertwhen closing TLS connections,
which led to "unexpected EOF while reading" errors in strict clients such as
openssl s_client.This commit fixes the issue by explicitly sending a
close_notifyrecord.This ensures that TLS sessions are terminated cleanly.
Fixes: #7476
Checklist