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

Fix the use of default OpenSSL ciphers #3107

Closed
wants to merge 3 commits into from

Conversation

pquentin
Copy link
Member

@pquentin pquentin commented Aug 9, 2023

Closes #3100

Copy link
Contributor

@sigmavirus24 sigmavirus24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for debugging this @pquentin

Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pquentin and @illia-v!

@pquentin
Copy link
Member Author

Thanks for the reviews. So the reason I have not merged yet is that I first thought that DEFAULT would be the system default, to allow users to control the ciphers, but I have not managed to do that on Fedora or Ubuntu. So this still needs some investigation.

@sshishov
Copy link

Am I missing something here? This MR is almost completely the same as #3060
And where @pquentin rejected the change. Did we discover something new? Like defaults from Cython?

@sethmlarson
Copy link
Member

@sshishov My understanding is "DEFAULT" is different than the system configured default, which is what we want. However, CPython has started setting a default which means that we're unable to revert to the true system default.

@elminson
Copy link

elminson commented Oct 16, 2023

Am I missing something here? This MR is almost completely the same as #3060 And where @pquentin rejected the change. Did we discover something new? Like defaults from Cython?

🤷‍♂️ @sshishov had same question :)

@pquentin
Copy link
Member Author

Sorry for not updating this earlier. The reason using "DEFAULT" does not work is that CPython sets its own ciphers in a way that user code cannot control, using Hynek's list (the one we use in 1.26.x):

#elif PY_SSL_DEFAULT_CIPHERS == 1
/* Python custom selection of sensible cipher suites
 * @SECLEVEL=2: security level 2 with 112 bits minimum security (e.g. 2048 bits RSA key)
 * ECDH+*: enable ephemeral elliptic curve Diffie-Hellman
 * DHE+*: fallback to ephemeral finite field Diffie-Hellman
 * encryption order: AES AEAD (GCM), ChaCha AEAD, AES CBC
 * !aNULL:!eNULL: really no NULL ciphers
 * !aDSS: no authentication with discrete logarithm DSA algorithm
 * !SHA1: no weak SHA1 MAC
 * !AESCCM: no CCM mode, it's uncommon and slow
 *
 * Based on Hynek's excellent blog post (update 2021-02-11)
 * https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
 */
  #define PY_SSL_DEFAULT_CIPHER_STRING "@SECLEVEL=2:ECDH+AESGCM:ECDH+CHACHA20:ECDH+AES:DHE+AES:!aNULL:!eNULL:!aDSS:!SHA1:!AESCCM"
  #ifndef PY_SSL_MIN_PROTOCOL
    #define PY_SSL_MIN_PROTOCOL TLS1_2_VERSION
  #endif

Ideally it should stop doing that, but before asking we should probably look at actual defaults in recent versions to see how good they are. In the meantime, https://quentin.pradet.me/blog/fixing-sslv3_alert_handshake_failure-with-urllib3-20.html continues to be the official guidance to fix handshake failures in urllib3. Closing.

@pquentin pquentin closed this Aug 16, 2024
@pquentin pquentin deleted the openssl-default-ciphers branch August 16, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Behavior change: v2.x raises SSLEOFError with Python3.10 where v2.x does not with Python3.8
5 participants