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

gh-99951: Warn if there is an OpenSSL major version mismatch #100641

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

moonsikpark
Copy link

@moonsikpark moonsikpark commented Dec 31, 2022

While it is a rare edge case well beyond the average use case, there could be situation where there is an OpenSSL version mismatch between the version python was compiled against, and the version currently loaded. Because OpenSSL states that major releases can break compatibility with previous versions and checks are cheap, there seems to be no harm if python warns when it happens.

tl;dr: This PR warns users when importing the ssl module when the OpenSSL major version mismatch between the version python was compiled against, and the one it is using.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Dec 31, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

bedevere-bot commented Dec 31, 2022

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

This reverts commit f9171f0.
@moonsikpark moonsikpark force-pushed the gh-99951-warn-different-openssl-major-versions branch from 09e600e to c88b3d9 Compare Dec 31, 2022
Copy link
Contributor

@eli-schwartz eli-schwartz left a comment

IMO this is really a Node.js bug for exposing bad symbols, but arguing that it's a bug in the other program does still leave python users having issues so I guess there's a rationale to say python might still want to check it.

That being said, I don't think this is the right fix, it should be an error as it's guaranteed to not work -- you should be prevented from successfully importing the module, just like you would be if the _ssl module failed to load because the libssl library was missing, rather than being overridden.

(Maybe the error should be raised in _ssl rather than ssl? idk)

f"{_OPENSSL_API_VERSION[0]}.{_OPENSSL_API_VERSION[1]}, "
"but is using OpenSSL "
f"{OPENSSL_VERSION_INFO[0]}.{OPENSSL_VERSION_INFO[1]}. "
"OpenSSL does not guarantee compatibility between different major versions.",
Copy link
Contributor

@eli-schwartz eli-schwartz Jan 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect -- it's guaranteed to not work. :P

On Linux, at least, openssl's util/mkdef.pl ensures the build has versioned symbols, specifically to ensure that it's safe to load multiple libssl libraries into a single process and you will always get the symbols you actually linked to, and cannot ever get the ones you are guaranteed to be unable to safely and compatibly use.

@eli-schwartz
Copy link
Contributor

eli-schwartz commented Jan 1, 2023

The best way to check this would be to compare openssl/opensslv.h SHLIB_VERSION_NUMBER (1.1) or OPENSSL_SHLIB_VERSION (3.0) at build and runtime, but it's only available as a header macro... this is the information you want though, since it specifically encodes the ABI compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants