from urllib.parse import urlsplit
+import warnings
+from requests.adapters import HTTPAdapter
+from requests.packages.urllib3.util.ssl_ import create_urllib3_context
import requests
import requests_ftp
return '' # Alas, requests_ftp doesn't store welcome message
+# See https://lukasa.co.uk/2017/02/Configuring_TLS_With_Requests/
+
+class AllCiphersAdapter(HTTPAdapter):
+ """
+ A TransportAdapter that re-enables 3DES support in Requests.
+ """
+ def init_poolmanager(self, *args, **kwargs):
+ context = create_urllib3_context(cert_reqs=0,
+ ciphers='ALL:@SECLEVEL=1')
+ kwargs['ssl_context'] = context
+ return super(AllCiphersAdapter, self).init_poolmanager(*args, **kwargs)
+
+ def proxy_manager_for(self, *args, **kwargs):
+ context = create_urllib3_context(cert_reqs=0,
+ ciphers='ALL:@SECLEVEL=1')
+ kwargs['ssl_context'] = context
+ return super(AllCiphersAdapter, self).proxy_manager_for(
+ *args, **kwargs)
+
+
+warnings.filterwarnings('ignore', 'Unverified HTTPS request is being made')
+
+
def request_get(url, headers, timeout, proxy):
if proxy:
proxies = {'http': proxy, 'https': proxy}
else:
proxies = None
+ s = requests.Session()
+ s.mount('https://', AllCiphersAdapter())
+
try:
- r = requests.Session().get(
- url, headers=headers, timeout=timeout,
- allow_redirects=False, proxies=proxies)
+ r = s.get(url, headers=headers, timeout=timeout,
+ allow_redirects=False, proxies=proxies,
+ verify=False)
except requests.RequestException as e:
return str(e), None
else: