PYTHON-4492 Fallback to stdlib ssl when pyopenssl import fails with AttributeError #1669
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.
Catch
AttributeError
caused by incompatibility between PyOpenSSL < 23.2.0 & cryptography >= 42.0.0.In a situation where incompatible versions are already installed on the system (regardless
pip install "pymongo[ocsp]"
as noticed in https://jira.mongodb.org/browse/PYTHON-4491), the user now gets an unhandled exception with a stack trace:The added exception handling tries to fix this problem by falling back to stdlib SSL as would happen if the PyOpenSSL was not installed at all. Additionally, the stack trace is replaced with a user-friendly warning suggesting a possible solution in case the OCSP support is desired.
Ref. cve-search/cve-search#1099 (comment), conda/conda#13619 (comment) & #1666.