[Python] How to set default ciphers for Python Requests library when using urllib3 ver > 2.0.0

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    urllib3 removed the ability to change DEFAULT_CIPHER in the major version 2.0.0. This was the main way to get around the error:

    requests.exceptions.SSLError: [SSL: SSL_NEGATIVE_LENGTH] dh key too small (_ssl.c:600)


    on the client side.

    Is there anyway to change the default cipher now in urllib3 ver > 2.0.0. or another way to get around this error?

    Previously I had been receiving the error:

    requests.exceptions.SSLError: [SSL: SSL_NEGATIVE_LENGTH] dh key too small (_ssl.c:600)


    when using the requests library, which I eventually was able to get around using the line:

    requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL:mad:SECLEVEL=1'


    However, after getting a new laptop and reinstalling my packages, I began to get the original error again. After doing a bunch of research, I believe the issue is that on my new laptop, I've installed urllib3 2.0.3 which removed the "DEFAULT_CIPHERS" as seen in the changelog for version 2.0.0: Removed DEFAULT_CIPHERS, HAS_SNI, USE_DEFAULT_SSLCONTEXT_CIPHERS, from the private module urllib3.util.ssl_

    Preferably without having to downgrade my urllib3 to an older version, does anyone know how to change the default ciphers again so I can get around the dh key too small error?

    Thanks

    Continue reading...

Compartilhe esta Página