on master help sign in
[mod] upgrade requests to version 2.24.0. use ssl instead of pyopenssl.
93f7f7eAlexandre Flament
requirements.txt+3−3
@@ -1,12 +1,12 @@
1−certifi==2020.4.5.1
1+certifi==2020.6.20
2babel==2.7.0
2babel==2.7.0
3flask-babel==1.0.0
3flask-babel==1.0.0
4flask==1.1.2
4flask==1.1.2
5−idna==2.9
5+idna==2.10
6jinja2==2.11.1
6jinja2==2.11.1
7lxml==4.5.0
7lxml==4.5.0
8pygments==2.1.3
8pygments==2.1.3
9pyopenssl==19.1.0
9pyopenssl==19.1.0
10python-dateutil==2.8.0
10python-dateutil==2.8.0
11pyyaml==5.3.1
11pyyaml==5.3.1
12−requests[socks]==2.23.0
12+requests[socks]==2.24.0
searx/__init__.py−9
@@ -15,12 +15,10 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
15(C) 2013- by Adam Tauber, <asciimoo@gmail.com>
15(C) 2013- by Adam Tauber, <asciimoo@gmail.com>
16'''
16'''
17
17
18−import certifi
19import logging
18import logging
20from os import environ
19from os import environ
21from os.path import realpath, dirname, join, abspath, isfile
20from os.path import realpath, dirname, join, abspath, isfile
22from io import open
21from io import open
23−from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
24from yaml import safe_load
22from yaml import safe_load
25
23
26
24
@@ -81,13 +79,6 @@ else:
81
79
82logger = logging.getLogger('searx')
80logger = logging.getLogger('searx')
83logger.debug('read configuration from %s', settings_path)
81logger.debug('read configuration from %s', settings_path)
84−# Workaround for openssl versions <1.0.2
85−# https://github.com/certifi/python-certifi/issues/26
86−if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2):
87− if hasattr(certifi, 'old_where'):
88− environ['REQUESTS_CA_BUNDLE'] = certifi.old_where()
89− logger.warning('You are using an old openssl version({0}), please upgrade above 1.0.2!'.format(OPENSSL_VERSION))
90−
91logger.info('Initialisation done')
82logger.info('Initialisation done')
92
83
93if 'SEARX_SECRET' in environ:
84if 'SEARX_SECRET' in environ:
searx/poolrequests.py+27−3
@@ -1,9 +1,33 @@
1−import requests
1+import sys
2−
2+from time import time
3from itertools import cycle
3from itertools import cycle
4from threading import RLock, local
4from threading import RLock, local
5+
6+import requests
7+
5from searx import settings
8from searx import settings
6−from time import time
9+from searx import logger
10+
11+
12+logger = logger.getChild('poolrequests')
13+
14+
15+try:
16+ import ssl
17+ if ssl.OPENSSL_VERSION_INFO[0:3] < (1, 0, 2):
18+ # https://github.com/certifi/python-certifi#1024-bit-root-certificates
19+ logger.critical('You are using an old openssl version({0}), please upgrade above 1.0.2!'
20+ .format(ssl.OPENSSL_VERSION))
21+ sys.exit(1)
22+except ImportError:
23+ ssl = None
24+if not getattr(ssl, "HAS_SNI", False):
25+ try:
26+ import OpenSSL # pylint: disable=unused-import
27+ except ImportError:
28+ logger.critical("ssl doesn't support SNI and the pyopenssl module is not installed.\n"
29+ "Some HTTPS connections will fail")
30+ sys.exit(1)
7
31
8
32
9class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter):
33class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter):
searx/webapp.py−7
@@ -78,13 +78,6 @@ from searx.plugins.oa_doi_rewrite import get_doi_resolver
78from searx.preferences import Preferences, ValidationException, LANGUAGE_CODES
78from searx.preferences import Preferences, ValidationException, LANGUAGE_CODES
79from searx.answerers import answerers
79from searx.answerers import answerers
80
80
81−# check if the pyopenssl package is installed.
82−# It is needed for SSL connection without trouble, see #298
83−try:
84− import OpenSSL.SSL # NOQA
85−except ImportError:
86− logger.critical("The pyopenssl package has to be installed.\n"
87− "Some HTTPS connections will fail")
88
81
89# serve pages with HTTP/1.1
82# serve pages with HTTP/1.1
90from werkzeug.serving import WSGIRequestHandler
83from werkzeug.serving import WSGIRequestHandler