-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Newest version cause DeprecationWarning: 'urllib3.contrib.pyopenssl' module is deprecated #2744
Comments
Hi @ddzialak, Botocore doesn't use pyopenssl, we have intentionally patched it to always use the standard library version of SSLContext. There's a lingering import from the pyopenssl module for backwards compatibility which appears to be triggering the warning. If we were impacted we're already pinned to |
@ddzialak You likely have
or similar in your Py.test configuration, causing deprecation warnings (such as this one) at test-dependency module import time to become errors. You could configure that to something like
to let this particular warning slip. |
@nateprewitt code is not importing Seems to me that this could be start to be solved by reversing the logic here: botocore/botocore/httpsession.py Lines 39 to 43 in d10816a
to something like from urllib3.util.ssl_ import SSLContext
if SSLContext is None:
from urllib3.contrib.pyopenssl import orig_util_SSLContext as SSLContext of if preserving the try:
from urllib3.util.ssl_ import SSLContext
if SSLContext is None:
raise ImportError
except ImportError:
from urllib3.contrib.pyopenssl import orig_util_SSLContext as SSLContext Thus providing the non-deprecated context if it's available from urllib3, and fall back to pyopenssl for backwards compatibility |
Hi @miketheman, the import order is intentional for handling the original injection mechanism used for pyopenssl. The value of You can do a quick check to validate this: from urllib3.contrib.pyopenssl import orig_util_SSLContext as orig_SSLContext
from ssl import SSLContext
assert orig_SSLContext == SSLContext
import urllib3
urllib3.contrib.pyopenssl.inject_into_urllib3()
from urllib3.util.ssl_ import SSLContext as urllib3_SSLContext
assert urllib3_SSLContext == SSLContext, f"SSLContext is {urllib3_SSLContext}" This is due to the value being patched out with old versions of Requests and urllib3 where pyopenssl is present in the environment. Our best option is likely to suppress the specific warning with something like catch_warnings as our exception logic will handle its removal in the future. Once the pyopenssl injection mechanism is removed in 2.0, we'll consistently fallback to the unpatched |
Hi all this was addressed in #2763. Closing this out. |
Why is this lingering import kept at all? AFAIU the Also, since when suppressing a deprecation warning fixes anything? |
Apologies if my last comment was unclear. This import is specifically to not use pyopenssl and avoid its import if present. We are working around a behavior of older versions of requests/urllib3, botocore has never used pyopenssl. A simplified example of how this happens in production systems: $ python -m pip install requests==2.22.0
$ python -m pip install pyopenssl
$ python
>>> import requests
>>> import urllib3
>>> urllib3.util.ssl_.SSLContext
<class 'urllib3.contrib.pyopenssl.PyOpenSSLContext'> urllib3 patches the value of SSLContext when
From the urllib3 team's perspective, we actively test botocore in the urllib3 test suite itself. This is a known import that is safe behavior, so the warning doesn't apply. Suppressing it is the best option to avoid misleading noise. The code already handles the upcoming removal gracefully. |
Looks like we are using PyOpenSSL < 22.0 which can cause issues with the newer version of cryptography module that causes AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' . Check boto/botocore#2744 urllib3/urllib3#2680 for more details. The problem was that when we call install-dependencies, it downloads requirements.txt and then requirement_test.txt. When we download requirement_test.txt, we don't have -U flag, and then this means some of dependencies are not upgraded as stated inside requirement_test.txt. I tried adding -U flag to the PR Signed-off-by: SangBin Cho <[email protected]>
Looks like we are using PyOpenSSL < 22.0 which can cause issues with the newer version of cryptography module that causes AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' . Check boto/botocore#2744 urllib3/urllib3#2680 for more details. The problem was that when we call install-dependencies, it downloads requirements.txt and then requirement_test.txt. When we download requirement_test.txt, we don't have -U flag, and then this means some of dependencies are not upgraded as stated inside requirement_test.txt. I tried adding -U flag to the PR Signed-off-by: SangBin Cho <[email protected]> Signed-off-by: Weichen Xu <[email protected]>
Describe the bug
Fresh installation cause warning:
That warning somehow cause, that
pytest
does not start tests.Expected Behavior
import of botocore should not issue that warning
Current Behavior
DeprecationWarning
is issuedReproduction Steps
after fresh installation:
Possible Solution
avoid import of
urllib3.contrib.pyopenssl
, for more see:urllib3/urllib3#2680
Additional Information/Context
Workaround: enforcing version
urllib3==1.26.9
solve that issueSDK version used
Python 3.10.4
botocore 1.27.56
Environment details (OS name and version, etc.)
Linux darek-dell 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: