-
-
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
ssl.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1131) #2653
Comments
see also python/cpython#93927 |
What is the output of To solve the issue, you need a custom SSL context (again the StackOverflow answers explains how to do it). Thanks to @graingert's in Python 3.12 you will be able to switch from |
Thank you python -c 'import ssl; print(ssl.OPENSSL_VERSION) = OpenSSL 3.0.3 3 May 2022 Do I need to pass in Python 3.12, I am under Python 3.9 ? |
Python 3.12 will be released in October 2023, I just mentioned it for future readers. You can downgrade to OpenSSL 1.1.1 or use the following code: import urllib3
from urllib3.util.ssl_ import create_urllib3_context
ctx = create_urllib3_context()
ctx.load_default_certs()
ctx.options |= 0x4 # ssl.OP_LEGACY_SERVER_CONNECT
with urllib3.PoolManager(ssl_context=ctx) as http:
r = http.request("GET", "https://nomads.ncep.noaa.gov/")
print(r.status) |
Thank you that works well. |
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Feature image obeys width/height style attr
Ajuste do código (conforme sugerido em urllib3/urllib3#2653), para evitar erro "UNSAFE_LEGACY_RENEGOTIATION_DISABLED"
Really worked wonders for my case where I modified the given approach to cater to my case where I needed this with the requests library: import urllib3, requests
from urllib3.util.ssl_ import create_urllib3_context
from requests.adapters import HTTPAdapter
your_url = "https://nomads.ncep.noaa.gov/"
class ExampleCustomSslContextHttpAdapter(HTTPAdapter):
""""Transport adapter" that allows us to use a custom ssl context object with the requests."""
def init_poolmanager(self, connections, maxsize, block=False):
ctx = create_urllib3_context()
ctx.load_default_certs()
ctx.options |= 0x4 # ssl.OP_LEGACY_SERVER_CONNECT
self.poolmanager = urllib3.PoolManager(ssl_context=ctx)
session = requests.Session()
session.mount(your_url, CustomSslContextHttpAdapter())
response = session.get(your_url) This gave me required results! Thanks! Hope this helps someone! |
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Ubuntu 22.04 has new OpenSSL, which is too strict. Fix based on urllib3/urllib3#2653
Subject
Error on SSL Connection
Environment
OS Windows-10-10.0.19044-SP0
Python 3.8.12
urllib3 1.26.8
Steps to Reproduce
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: