also update urllib3's cipher list for versions >= 1.25

This commit is contained in:
Mike Fährmann 2019-05-21 23:00:00 +02:00
parent f837ea98cb
commit 399e8e965a
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -403,32 +403,30 @@ def generate_extractors(extractor_data, symtable, classes):
http.cookiejar.MozillaCookieJar.magic_re = re.compile(
"#( Netscape)? HTTP Cookie File", re.IGNORECASE)
# Update default cipher list of urllib3 < 1.25
# Update default cipher list of urllib3
# to fix issues with Cloudflare and, by extension, Artstation (#227)
import requests.packages.urllib3 as urllib3 # noqa
if urllib3.__version__ < "1.25":
from requests.packages.urllib3.util import ssl_
logging.getLogger("gallery-dl").debug(
"updating default urllib3 ciphers")
# cipher list taken from urllib3 1.25
# https://github.com/urllib3/urllib3/blob/1.25/src/urllib3/util/ssl_.py
# with additions from
# https://github.com/Anorov/cloudflare-scrape/pull/242
ssl_.DEFAULT_CIPHERS = (
"ECDHE+AESGCM:"
"ECDHE+CHACHA20:"
"DHE+AESGCM:"
"DHE+CHACHA20:"
"ECDH+AESGCM:"
"DH+AESGCM:"
"ECDH+AES:"
"DH+AES:"
"RSA+AESGCM:"
"RSA+AES:"
"!ECDHE+SHA:"
"!AES128-SHA:"
"!aNULL:"
"!eNULL:"
"!MD5:"
"!DSS"
)
from requests.packages.urllib3.util import ssl_ # noqa
logging.getLogger("gallery-dl").debug("updating default urllib3 ciphers")
# cipher list taken from urllib3 1.25
# https://github.com/urllib3/urllib3/blob/1.25/src/urllib3/util/ssl_.py
# with additions from
# https://github.com/Anorov/cloudflare-scrape/pull/242
ssl_.DEFAULT_CIPHERS = (
"ECDHE+AESGCM:"
"ECDHE+CHACHA20:"
"DHE+AESGCM:"
"DHE+CHACHA20:"
"ECDH+AESGCM:"
"DH+AESGCM:"
"ECDH+AES:"
"DH+AES:"
"RSA+AESGCM:"
"RSA+AES:"
"!ECDHE+SHA:"
"!AES128-SHA:"
"!aNULL:"
"!eNULL:"
"!MD5:"
"!DSS"
)