diff options
author | Alexandre Flament <alex@al-f.net> | 2020-09-15 10:54:31 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-09-26 19:30:27 +0200 |
commit | 93f7f7eee2e843b3b3057b7854508c68c6432f3e (patch) | |
tree | f1b46097be9ca1a2061c6962f7e7a6fa5e5b2399 /searx/poolrequests.py | |
parent | 21dbc7e852a5c48097c0067e78f0600972e54823 (diff) | |
download | searxng-93f7f7eee2e843b3b3057b7854508c68c6432f3e.tar.gz searxng-93f7f7eee2e843b3b3057b7854508c68c6432f3e.zip |
[mod] upgrade requests to version 2.24.0. use ssl instead of pyopenssl.
requests 2.24.0 uses the ssl module except if it doesn't support SNI, in this case searx fallbacks to pyopenssl.
searx logs a critical message and exit if the ssl modules doesn't support SNI and pyOpenSSL is not installed.
searx logs a critical message and exit if the ssl version is older than 1.0.2.
in requirements.txt, pyopenssl is still required to install searx as a fallback.
Diffstat (limited to 'searx/poolrequests.py')
-rw-r--r-- | searx/poolrequests.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/searx/poolrequests.py b/searx/poolrequests.py index 51b6219c3..e03797ce2 100644 --- a/searx/poolrequests.py +++ b/searx/poolrequests.py @@ -1,9 +1,33 @@ -import requests - +import sys +from time import time from itertools import cycle from threading import RLock, local + +import requests + from searx import settings -from time import time +from searx import logger + + +logger = logger.getChild('poolrequests') + + +try: + import ssl + if ssl.OPENSSL_VERSION_INFO[0:3] < (1, 0, 2): + # https://github.com/certifi/python-certifi#1024-bit-root-certificates + logger.critical('You are using an old openssl version({0}), please upgrade above 1.0.2!' + .format(ssl.OPENSSL_VERSION)) + sys.exit(1) +except ImportError: + ssl = None +if not getattr(ssl, "HAS_SNI", False): + try: + import OpenSSL # pylint: disable=unused-import + except ImportError: + logger.critical("ssl doesn't support SNI and the pyopenssl module is not installed.\n" + "Some HTTPS connections will fail") + sys.exit(1) class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter): |