Skip to content
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

bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH-25309) #25309

Merged
merged 1 commit into from Apr 9, 2021

Conversation

tiran
Copy link
Member

@tiran tiran commented Apr 9, 2021

Signed-off-by: Christian Heimes <christian@python.org>
@tiran tiran changed the title bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH-25309) Apr 9, 2021
@tiran tiran merged commit 6f37ebc into python:master Apr 9, 2021
11 checks passed
@miss-islington
Copy link
Contributor

miss-islington commented Apr 9, 2021

Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒🤖

@tiran tiran deleted the bpo-43794-ssl-eof branch Apr 9, 2021
@bedevere-bot
Copy link

bedevere-bot commented Apr 9, 2021

GH-25313 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 9, 2021
…thonGH-25309)

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <christian@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 9, 2021
…thonGH-25309)

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <christian@python.org>
@bedevere-bot
Copy link

bedevere-bot commented Apr 9, 2021

GH-25314 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Apr 9, 2021
…-25309)

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <christian@python.org>
miss-islington added a commit that referenced this pull request Apr 9, 2021
…-25309)

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <christian@python.org>
kreathon pushed a commit to kreathon/cpython that referenced this pull request May 2, 2021
davidben added a commit to davidben/cpython that referenced this pull request Jul 31, 2022
pythonGH-25309 enabled SSL_OP_IGNORE_UNEXPECTED_EOF by default, with a comment
that it restores OpenSSL 1.1.1 behavior, but this wasn't quite right.
That option causes OpenSSL to treat transport EOF as the same as
close_notify (i.e. SSL_ERROR_ZERO_RETURN), whereas Python actually has
distinct SSLEOFError and SSLZeroReturnError exceptions. (The latter is
usually mapped to a zero return from read.) In OpenSSL 1.1.1, the ssl
module would raise them for transport EOF and close_notify,
respectively. In OpenSSL 3.0, both act like close_notify.

Fix this by, instead, just detecting SSL_R_UNEXPECTED_EOF_WHILE_READING
and mapping that to the other exception type.

There doesn't seem to have been any unit test of this error, so fill in
the missing one. This had to be done with the BIO path because it's
actually slightly tricky to simulate a transport EOF with Python's fd
based APIs. (If you instruct the server to close the socket, it gets
confused, probably because the server's SSL object is still referencing
the now dead fd?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants