Skip to content

Commit

Permalink
workaround for requests 2.32.3 (#5665)
Browse files Browse the repository at this point in the history
manually call 'load_default_certs()' for SSLContexts
in custom HTTPAdapter instances
  • Loading branch information
mikf committed Jun 1, 2024
1 parent 330162f commit 6cfbc10
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gallery_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ def _build_requests_adapter(ssl_options, ssl_ciphers, source_address):
if ssl_options or ssl_ciphers:
ssl_context = urllib3.connection.create_urllib3_context(
options=ssl_options or None, ciphers=ssl_ciphers)
if requests.__version__ > "2.31":
# https://github.com/psf/requests/pull/6731
ssl_context.load_default_certs()
ssl_context.check_hostname = False
else:
ssl_context = None
Expand Down

3 comments on commit 6cfbc10

@fireattack
Copy link
Contributor

@fireattack fireattack commented on 6cfbc10 Jun 2, 2024

Choose a reason for hiding this comment

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

are we supposed to compare strings this way?

I currently use 2.31.0, which shouldn't need this workaround, but it would return True for requests.__version__ > "2.31" if you compare these two strings.

(Please let me know if it's not appropriate to comment on commit!)

@mikf
Copy link
Owner Author

@mikf mikf commented on 6cfbc10 Jun 2, 2024

Choose a reason for hiding this comment

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

This is definitely not the proper way, but it usually kind of works without having to convert the version string to numbers. Unless you make stupid mistakes like me ... and I even initially had it as not requests.__version__ < "2.32", which wouldn't have this issue I think.

(Please let me know if it's not appropriate to comment on commit!)

It is very appropriate when pointing out mistakes like this.

@mikf
Copy link
Owner Author

@mikf mikf commented on 6cfbc10 Jun 2, 2024

Choose a reason for hiding this comment

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

Fixed in 5d3d03a

Please sign in to comment.