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

gh-79846: Make ssl.create_default_context() ignore invalid certificates #91740

Closed
wants to merge 4 commits into from

Conversation

pukkandan
Copy link

@pukkandan pukkandan commented Apr 20, 2022

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 Serbia

See 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

# no explicit cafile, capath or cadata but the verify mode is
# CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system
# root CA certificates for the given purpose. This may fail silently.

This issue can be solved by loading each certificate one by one and ignoring any SSLErrors. 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

An error in one certificate should not cause the whole thing to crash

Fixes python#79846, python#89475
@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Apr 20, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Every change to Python requires a NEWS entry.

Please, add it using the blurb_it Web app or the blurb command-line tool.

@pukkandan pukkandan changed the title gh-79846: Load CA certificates one by one in ssl.create_default_context() gh-79846: Make ssl.create_default_context() ignore invalid certificates Apr 20, 2022
@serhiy-storchaka
Copy link
Member

The issues was closed and I cannot reproduce the original problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants