psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.2k stars 9.34k forks source link

Don't create default SSLContext if ssl module isn't present #6724

Closed nateprewitt closed 6 months ago

nateprewitt commented 6 months ago

This PR is to address a recent regression in Emscripten support for urllib3. We began unilaterally creating an SSLContext without consideration for Python versions built without an ssl module. This is handled in urllib3 but missed in our usage of create_urllib3_context.

This PR expands on the fix in #6716 by also evaluating both the presence of the ssl module before creating and setting the default SSLContext.

AdamWill commented 3 months ago

We also need to do this for FileNotFoundError, which is raised if DEFAULT_CA_BUNDLE_PATH isn't there. Sent as https://github.com/psf/requests/pull/6781 .