-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
gh-79846: Make ssl.create_default_context()
ignore invalid certificates
#91740
Conversation
An error in one certificate should not cause the whole thing to crash Fixes python#79846, python#89475
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
ssl.create_default_context()
ssl.create_default_context()
ignore invalid certificates
The issues was closed and I cannot reproduce the original problem. |
This issue still seems to be a problem. |
Lib/ssl.py
Outdated
if trust is True or purpose.oid in trust: | ||
certs.extend(cert) | ||
try: | ||
self.load_verify_locations(cadata=cert) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loads the certificate unconditionally, unlike the current code.
Workaround: `[ASN1] nested asn1 error` error when making HTTPS connections on systems with certificates that OpenSSL cannot parse are installed. This is a general issue with Python, resolve by applying a proposed fix [0] to the extensions Python process at run-time. (this doesn't impact Blender's Python run-time). The down side is HTTPS connections will only work for extensions on systems with this problem so this needs to be resolved by Python long term. While any changes to Python's SSL checks is worth avoiding, this simply skips SSL certificates in the windows store that OpenSSL can't parse instead of failing all SSL connections. See related issues: - python/cpython#79846 - openssl/openssl#25023 [0]: python/cpython#91740 Ref !124943.
Is calling |
Workaround: `[ASN1] nested asn1 error` error when making HTTPS connections on systems with certificates that OpenSSL cannot parse are installed. This is a general issue with Python, resolve by applying a proposed fix [0] to the extensions Python process at run-time. (this doesn't impact Blender's Python run-time). The down side is HTTPS connections will only work for extensions on systems with this problem so this needs to be resolved by Python long term. While any changes to Python's SSL checks is worth avoiding, this simply skips SSL certificates in the windows store that OpenSSL can't parse instead of failing all SSL connections. See related issues: - python/cpython#79846 - openssl/openssl#25023 [0]: python/cpython#91740 Ref !124943.
There are tests that call I have no plausible scenario in which it would replace the old loaded certificates, but can detect duplicates in statistics. Looking at the code of |
If it's tested, then that's fine. This change LGTM |
Thanks @pukkandan for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @pukkandan for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…ificates (pythonGH-91740) An error in one certificate should not cause the whole thing to fail. (cherry picked from commit 9e551f9) Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…ificates (pythonGH-91740) An error in one certificate should not cause the whole thing to fail. (cherry picked from commit 9e551f9) Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-122768 is a backport of this pull request to the 3.13 branch. |
GH-122769 is a backport of this pull request to the 3.12 branch. |
…ificates (pythonGH-91740) An error in one certificate should not cause the whole thing to fail. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…tificates (GH-91740) (#122768) gh-79846: Make ssl.create_default_context() ignore invalid certificates (GH-91740) An error in one certificate should not cause the whole thing to fail. (cherry picked from commit 9e551f9) Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Fixes #79846, fixes #89475
Currently, when loading certificates from the Windows certificate store, error in any one certificate causes
ssl.create_default_context()
to crash. This causes issues in systems that have certificates that are not quite to-spec. A primary culprit for this is "MUPCA Root", which (despite being is technically invalid) is essential for citizens of SerbiaSee the conversations under the linked issues for more details
I believe it makes sense for
create_default_context
to ignore any invalid certificates in the system store. An existing comment in the related code seems to agree with me on this:cpython/Lib/ssl.py
Lines 772 to 774 in 8497514
This issue can be solved by loading each certificate one by one and ignoring any
SSLError
s. I had outlined the idea for this patch in the above-mentioned issue, but never recieved any reply on whether this is acceptable. Hopefully, this PR receives better attention