mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-23 08:38:16 +00:00
[Win32] Fix missing certs for HTTPS requests
The following error occured on Windows when switching to using HTTPS url with Twisted Agent: ``` <class 'twisted.web._newclient.ResponseNeverReceived'>: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]> ``` The fix is to install certifi and provide the path to the trust store as env var for OpenSSL to pick up. Also includes a simplication of the core test_listen_port code.
This commit is contained in:
parent
3fab799dbf
commit
e626f9fece
@ -32,6 +32,7 @@ install:
|
||||
pip install
|
||||
tox
|
||||
pywin32
|
||||
certifi
|
||||
)
|
||||
- if not defined TOXENV (
|
||||
pip install
|
||||
@ -44,6 +45,7 @@ install:
|
||||
slimit
|
||||
setproctitle
|
||||
pywin32
|
||||
certifi
|
||||
pygame
|
||||
bbfreeze
|
||||
pefile
|
||||
|
@ -40,6 +40,12 @@ except ImportError:
|
||||
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
||||
from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports
|
||||
|
||||
# Windows workaround for HTTPS requests requiring certificate authority bundle.
|
||||
# see: https://twistedmatrix.com/trac/ticket/9209
|
||||
if platform.system() in ('Windows', 'Microsoft'):
|
||||
from certifi import where
|
||||
os.environ['SSL_CERT_FILE'] = where()
|
||||
|
||||
DBUS_FILEMAN = None
|
||||
# gi makes dbus available on Window but don't import it as unused.
|
||||
if platform.system() not in ('Windows', 'Microsoft', 'Darwin'):
|
||||
|
@ -1121,23 +1121,15 @@ class Core(component.Component):
|
||||
port = self.get_listen_port()
|
||||
url = 'https://deluge-torrent.org/test_port.php?port=%s' % port
|
||||
agent = Agent(reactor, connectTimeout=30)
|
||||
d = agent.request(
|
||||
b'GET',
|
||||
url.encode('utf-8'),
|
||||
)
|
||||
d = agent.request(b'GET', url.encode())
|
||||
|
||||
def on_get_page(response):
|
||||
d = readBody(response)
|
||||
d.addCallback(on_read_body)
|
||||
return d
|
||||
|
||||
def on_read_body(body):
|
||||
def on_get_page(body):
|
||||
return bool(int(body))
|
||||
|
||||
def on_error(failure):
|
||||
log.warning('Error testing listen port: %s', failure)
|
||||
|
||||
d.addCallback(on_get_page)
|
||||
d.addCallback(readBody).addCallback(on_get_page)
|
||||
d.addErrback(on_error)
|
||||
|
||||
return d
|
||||
|
Loading…
x
Reference in New Issue
Block a user