Report a TLS close without close_notify as EOF - #845
Open
benubois wants to merge 1 commit into
Open
Conversation
OpenSSL 3 raises "SSL_read: unexpected eof while reading" instead of signalling end of stream when a peer closes the connection without a close_notify alert. Nothing in the read path rescued it: the error is not an EOFError, and OpenSSL::SSL::SSLError is not one of the IOError, SocketError or SystemCallError that read_more converts, so it escaped as a bare OpenSSL error that callers cannot rescue through HTTP::Error. That also meant TLS never reached #check_premature_eof, so the same server behaviour produced a clean body over http and an exception over https. Reporting the close as EOF puts TLS back on that path, where the response framing decides: a body delimited by connection close finishes normally, one framed by Content-Length or chunked encoding that ends early raises HTTP::ConnectionError. Other SSL errors still propagate. Global#read_nonblock moves to Null so both polling handlers share one translation, and nil already means EOF to each of their callers.
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.
OpenSSL 3 raises
SSL_read: unexpected eof while readinginstead of signalling end of stream when a peer closes the connection without aclose_notifyalert. Nothing rescues it, so it escapes as a bare OpenSSL error.Reproduction
Seems to be related to
:auto_inflateContent-Length: 186934,Connection: closeContent-Encoding: gzip, noContent-Length, noTransfer-EncodingWith a
Content-Lengththe parser finishes on the length and never issues the read that would notice the close. Asking for gzip drops theContent-Length, so the body runs until the connection closes, and that read is the one that raises.