From 201928d2b0d9f7a3a3c3033f7e20838f67a05457 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sun, 26 Apr 2015 12:04:29 +0200 Subject: [PATCH 1/3] [fix] SSL : SNI support --- requirements.txt | 5 +++++ searx/engines/btdigg.py | 4 ---- searx/engines/kickass.py | 4 ---- searx/engines/photon.py | 3 --- setup.py | 5 +++++ versions.cfg | 5 +++++ 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2d434825d..e021c4a25 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,8 @@ lxml pyyaml pygments python-dateutil +ndg-httpsclient +pyopenssl +pyasn1 +pyasn1-modules +certifi diff --git a/searx/engines/btdigg.py b/searx/engines/btdigg.py index d0f05ec2d..944250628 100644 --- a/searx/engines/btdigg.py +++ b/searx/engines/btdigg.py @@ -29,10 +29,6 @@ def request(query, params): params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno']-1) - # FIX: SSLError: hostname 'btdigg.org' - # doesn't match either of 'ssl2000.cloudflare.com', 'cloudflare.com', '*.cloudflare.com' - params['verify'] = False - return params diff --git a/searx/engines/kickass.py b/searx/engines/kickass.py index ea7f17c23..9c4639c32 100644 --- a/searx/engines/kickass.py +++ b/searx/engines/kickass.py @@ -34,10 +34,6 @@ def request(query, params): params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno']) - # FIX: SSLError: hostname 'kickass.so' - # doesn't match either of '*.kickass.to', 'kickass.to' - params['verify'] = False - return params diff --git a/searx/engines/photon.py b/searx/engines/photon.py index a9c558c4b..869916cd4 100644 --- a/searx/engines/photon.py +++ b/searx/engines/photon.py @@ -41,9 +41,6 @@ def request(query, params): # using searx User-Agent params['headers']['User-Agent'] = searx_useragent() - # FIX: SSLError: SSL3_GET_SERVER_CERTIFICATE:certificate verify failed - params['verify'] = False - return params diff --git a/setup.py b/setup.py index fcbbfb728..6ecbca23c 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,11 @@ setup( 'pygments', 'setuptools', 'python-dateutil', + 'pyopenssl', + 'ndg-httpsclient', + 'pyasn1', + 'pyasn1-modules', + 'certifi' ], extras_require={ 'test': [ diff --git a/versions.cfg b/versions.cfg index 7f1734908..1c6f15d40 100644 --- a/versions.cfg +++ b/versions.cfg @@ -32,6 +32,11 @@ speaklater = 1.3 unittest2 = 0.5.1 waitress = 0.8.8 zc.recipe.testrunner = 2.0.0 +pyopenssl = 0.15.1 +ndg-httpsclient = 0.3.3 +pyasn1 = 0.1.7 +pyasn1-modules = 0.0.5 +certifi = 14.05.14 # Required by: # WebTest==2.0.11 From 2be52b74ad9e30474d553750d802199ee8cc4844 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sun, 26 Apr 2015 12:34:09 +0200 Subject: [PATCH 2/3] [fix] tests --- searx/tests/engines/test_kickass.py | 1 - 1 file changed, 1 deletion(-) diff --git a/searx/tests/engines/test_kickass.py b/searx/tests/engines/test_kickass.py index 971d0847e..4cfcaa63c 100644 --- a/searx/tests/engines/test_kickass.py +++ b/searx/tests/engines/test_kickass.py @@ -15,7 +15,6 @@ class TestKickassEngine(SearxTestCase): self.assertIn('url', params) self.assertIn(query, params['url']) self.assertIn('kickass.to', params['url']) - self.assertIn('verify', params) self.assertFalse(params['verify']) def test_response(self): From 187617498a0dea17e51950f1ad5e96bb4826367d Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sun, 26 Apr 2015 18:58:31 +0200 Subject: [PATCH 3/3] Log an error if the ndg-httpsclient, pyopenssl and pyasn1 packages are not installed. See #298 --- searx/webapp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/searx/webapp.py b/searx/webapp.py index 13c965e0d..38780220e 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -61,6 +61,16 @@ except: from sys import exit exit(1) +# check if the pyopenssl, ndg-httpsclient, pyasn1 packages are installed. +# They are needed for SSL connection without trouble, see #298 +try: + import OpenSSL.SSL # NOQA + import ndg.httpsclient # NOQA + import pyasn1 # NOQA +except ImportError: + logger.critical("The pyopenssl, ndg-httpsclient, pyasn1 packages have to be installed.\n" + "Some HTTPS connections will failed") + logger = logger.getChild('webapp')