GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH-25309) by tiran · Pull Request #25309 · python/cpython

Conversation

@tiran

@tiran tiran commented Apr 9, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Signed-off-by: Christian Heimes [email protected]

https://bugs.python.org/issue43794

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tiran
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default
ae65096
Signed-off-by: Christian Heimes <[email protected]>
@tiran tiran added needs backport to 3.8 labels Apr 9, 2021
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Apr 9, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Apr 9, 2021
@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
@miss-islington

miss-islington commented Apr 9, 2021

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tiran
tiran deleted the bpo-43794-ssl-eof branch April 9, 2021 15:59
@bedevere-bot bedevere-bot removed the awaiting core review label Apr 9, 2021
@bedevere-bot

bedevere-bot commented Apr 9, 2021

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 label Apr 9, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 9, 2021
@tiran @miss-islington
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
1688a22
…thonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 9, 2021
@tiran @miss-islington
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
1f6a5c8
…thonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.8 label Apr 9, 2021
@bedevere-bot

bedevere-bot commented Apr 9, 2021

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington added a commit that referenced this pull request Apr 9, 2021
@miss-islington @tiran
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH…
e18ebd9
…-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
miss-islington added a commit that referenced this pull request Apr 9, 2021
@miss-islington @tiran
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH…
54d89a3
…-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
This was referenced Jun 29, 2022
[Sidekiq 6.5.1] SSL_read: unexpected eof while reading sidekiq/sidekiq#5402
Closed
OpenSSL::SSL::SSLError: SSL_read: unexpected eof while reading redis/redis-rb#1106
Closed
tiran added a commit to tiran/cpython that referenced this pull request Jul 1, 2022
@tiran
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
9c16ffe
…thonGH-25309)
@edmorley edmorley mentioned this pull request Jul 6, 2022
SSL_read: unexpected eof while reading using redis-rb on Heroku-22 heroku/base-images#220
Closed
This was referenced Jul 31, 2022
ssl module with OpenSSL 3.0 does not throw SSLEOFError on unclean shutdown #95494
Closed
gh-95494: Fix transport EOF handling in OpenSSL 3.0 #95495
Merged
davidben added a commit to davidben/cpython that referenced this pull request Jul 31, 2022
@davidben
pythongh-95494: Fix transport EOF handling in OpenSSL 3.0
33dcd36
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?)
Yhg1s pushed a commit that referenced this pull request Mar 22, 2023
@davidben
GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495)
420bbb7
GH-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?)
This was referenced Mar 24, 2023
[3.11] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) #103006
Merged
[3.10] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) #103007
Merged
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 24, 2023
@davidben @miss-islington
pythonGH-95494: Fix transport EOF handling in OpenSSL 3.0 (pythonGH-9…
566770a
…5495)

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?)
(cherry picked from commit 420bbb7)

Co-authored-by: David Benjamin <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 24, 2023
@davidben @miss-islington
pythonGH-95494: Fix transport EOF handling in OpenSSL 3.0 (pythonGH-9…
39705d9
…5495)

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?)
(cherry picked from commit 420bbb7)

Co-authored-by: David Benjamin <[email protected]>
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
@davidben @Fidget-Spinner
pythonGH-95494: Fix transport EOF handling in OpenSSL 3.0 (pythonGH-9…
6a95610
…5495)

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?)
ambv pushed a commit that referenced this pull request Mar 27, 2023
@miss-islington @davidben
[3.11] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) (…
13df5d3
…#103006)

GH-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?)
(cherry picked from commit 420bbb7)

Co-authored-by: David Benjamin <[email protected]>
ambv pushed a commit that referenced this pull request Mar 27, 2023
@miss-islington @davidben
[3.10] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) (…
b5bf6c1
…#103007)

GH-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?)
(cherry picked from commit 420bbb7)

Co-authored-by: David Benjamin <[email protected]>
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@davidben @warsaw
pythonGH-95494: Fix transport EOF handling in OpenSSL 3.0 (pythonGH-9…
0602c17
…5495)

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?)
stratakis pushed a commit to stratakis/cpython that referenced this pull request Mar 11, 2024
@miss-islington @tiran @stratakis
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
3b6a849
…thonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
stratakis pushed a commit to stratakis/cpython that referenced this pull request Mar 25, 2024
@miss-islington @tiran @stratakis
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
a5b2560
…thonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
mcepl pushed a commit to openSUSE-Python/cpython that referenced this pull request Apr 2, 2024
@miss-islington @tiran @mcepl
bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (py…
5b46889
…thonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
icanhasmath added a commit to ActiveState/cpython that referenced this pull request Oct 30, 2026
@icanhasmath @benjaminp
@miss-islington @tiran @claude
3.7.17.9: move the 3.7 line to OpenSSL 3 (#126)
20146c9
* closes bpo-39953: Update OpenSSL error codes table. (pythonGH-19082)

I updated the error codes using the OpenSSL 1.1.1f source tree.

(cherry picked from commit 3e0dd37)

* closes bpo-39953: Generate ifdefs around library code definitions. (pythonGH-19490)

(cherry picked from commit 909b87d)

* closes bpo-40266, closes bpo-39953: Use numeric lib code if compiling against old OpenSSL. (pythonGH-19506)

(cherry picked from commit 584a3cf)

* bpo-43789: OpenSSL 3.0.0 Don't call passwd callback again in error case (pythonGH-25303)

(cherry picked from commit d3b73f3)

Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit a188bd4)

* bpo-4379: Skip TLS 1.0/1.1 tests under OpenSSL 3.0.0 (pythonGH-25304)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 5151d64)

Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit 4a5c101)

* bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (pythonGH-25309)

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 6f37ebc)

Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit 54d89a3)

* [3.9] bpo-43788: Generate version specific _ssl_data.h (pythonGH-25300) (pythonGH-25310)

(cherry picked from commit 150af75)

Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit 299ae9c)

* [3.9] bpo-46114: Fix OpenSSL version check for 3.0.1 (pythonGH-30170) (pythonGH-30173)

Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit a9b3edb)

* [3.9] bpo-41561: skip test_min_max_version_mismatch (pythonGH-22308) (pythonGH-23363)

skip test_min_max_version_mismatch when TLS 1.0 is not available

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit ce04e71)

Co-authored-by: Christian Heimes <[email protected]>

Automerge-Triggered-By: GH:tiran
(cherry picked from commit 802ff7c)

* 3.7.17.x: copy the OpenSSL DLLs by pattern on Windows

openssl.props copied libcrypto-1_1.dll and libssl-1_1.dll from the import
library directory, so building against OpenSSL 3 failed at the copy step.
OpenSSL 3 installs its DLLs in bin\ and names them libssl-3.dll or
libssl-3-x64.dll depending on how it was built; both forms occur among the
Platform's shared/openssl 3.5 builds.  python.props now sets opensslBinDir
(bin\ when OPENSSL_DIR has one, else the import library directory, which is
where 1.1 builds and the externals keep them), and openssl.props copies
whatever libcrypto-*/libssl-* DLLs and PDBs it finds there.

The ActiveState 3.9 builds get the same result from the Platform's core
patch, which computes the suffix instead.

* Doc: drop pasted citation markers from the 3.7.17.7 notes

The 3.7.17.7 section of Doc/whatsnew/3.7.rst carried source markers copied
along with its CVE descriptions ("NVD+5SUSE+5linux.oracle.com+5",
"starwindsoftware.com+2" and the like), which render as text.  The
descriptions themselves are unchanged.  The headings of the 3.7.17.4 to
3.7.17.7 sections also get underlines as long as their titles.

* Update version to 3.7.17.9 and add release notes

3.7.17.9 moves the 3.7 line to OpenSSL 3: the upstream ssl changes the
3.9 line got for OpenSSL 3 (unexpected-EOF handling, per-version error
tables, the password-callback fix and the matching test updates) and a
Windows build that copies OpenSSL 3's DLLs.  The notes list the behavior
changes that come with OpenSSL 3 itself.  OP_IGNORE_UNEXPECTED_EOF's
versionadded says 3.7.17.9, where this line gained it.

* 3.7.17.x: pick the OpenSSL DLL names from the OpenSSL version on Windows

Copying libssl-*.dll by wildcard broke the Platform's python-builder,
which edits openssl.props and stops when its x64 suffix line is missing.
Name the DLLs from SSL_MAJOR_VERSION/SSL_MINOR_VERSION (set by the
Platform build), detect a 3.x OpenSSL from bin\ when they are unset, and
add the x64 suffix only when that DLL exists.  python-builder removes
the x64 line, as it does for 3.9 and 3.10.

Co-Authored-By: Claude <[email protected]>

* 3.7.17.x: state the RSA key floor for each OpenSSL 3 default security level

OpenSSL 3.2 raised the default security level from 1 to 2, so the floor
is 2048 bits on the 3.5 release the Platform builds with and 1024 bits on
3.0 and 3.1.

---------

Co-authored-by: Benjamin Peterson <[email protected]>
Co-authored-by: Miss Islington (bot) <[email protected]>
Co-authored-by: Christian Heimes <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tiran @miss-islington @bedevere-bot @the-knights-who-say-ni
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.