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

SSL: DH_KEY_TOO_SMALL, Requests > 2.31.0 #6827

Closed
snooppr opened this issue Nov 15, 2024 · 1 comment
Closed

SSL: DH_KEY_TOO_SMALL, Requests > 2.31.0 #6827

snooppr opened this issue Nov 15, 2024 · 1 comment
Labels
actions/autoclose-qa Used for automation to auto-close an issue Question/Not a bug

Comments

@snooppr
Copy link

snooppr commented Nov 15, 2024

How to make requests to problematic sites (on old versions disabling shfires helped)?

import requests, urllib3

print(f"requests={requests.__version__}, urllib3={urllib3.__version__}")
requests=2.32.3, urllib3=1.26.18 (This version of Urllib3 still supports custom cipher selection.)

requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'

Error:
print(requests.get("https://nhl.ru"))
SSLError(SSLError(1, '[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1125)')))


python -m pip install requests==2.31.0

import requests, urllib3

print(f"requests={requests.__version__}, urllib3={urllib3.__version__}")
requests=2.31.0, urllib3=1.26.18

requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'

Good:
print(requests.get("https://nhl.ru"))
<Response [404]>


The latest version that works with the cipher changes Requests=2.31.0 and urllib3=1.26.18.

If you update, requests are bad: ('SSL: DH_KEY_TOO_SMALL')

Is there a way to make successful requests to old sites by playing with SSL (at the Python level, not the OS?).

For example:
Good:
curl -vLk "http://nhl.ru/" --ciphers 'DEFAULT:!DH'

@snooppr snooppr added actions/autoclose-qa Used for automation to auto-close an issue Question/Not a bug labels Nov 15, 2024
Copy link

As described in the template, we won't be able to answer questions on this issue tracker. Please use Stack Overflow

@github-actions github-actions bot locked as off-topic and limited conversation to collaborators Nov 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
actions/autoclose-qa Used for automation to auto-close an issue Question/Not a bug
Projects
None yet
Development

No branches or pull requests

1 participant