mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +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
3 changed files with 11 additions and 11 deletions
|
@ -32,6 +32,7 @@ install:
|
||||||
pip install
|
pip install
|
||||||
tox
|
tox
|
||||||
pywin32
|
pywin32
|
||||||
|
certifi
|
||||||
)
|
)
|
||||||
- if not defined TOXENV (
|
- if not defined TOXENV (
|
||||||
pip install
|
pip install
|
||||||
|
@ -44,6 +45,7 @@ install:
|
||||||
slimit
|
slimit
|
||||||
setproctitle
|
setproctitle
|
||||||
pywin32
|
pywin32
|
||||||
|
certifi
|
||||||
pygame
|
pygame
|
||||||
bbfreeze
|
bbfreeze
|
||||||
pefile
|
pefile
|
||||||
|
|
|
@ -40,6 +40,12 @@ except ImportError:
|
||||||
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
||||||
from urllib import pathname2url, unquote_plus # 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
|
DBUS_FILEMAN = None
|
||||||
# gi makes dbus available on Window but don't import it as unused.
|
# gi makes dbus available on Window but don't import it as unused.
|
||||||
if platform.system() not in ('Windows', 'Microsoft', 'Darwin'):
|
if platform.system() not in ('Windows', 'Microsoft', 'Darwin'):
|
||||||
|
|
|
@ -1121,23 +1121,15 @@ class Core(component.Component):
|
||||||
port = self.get_listen_port()
|
port = self.get_listen_port()
|
||||||
url = 'https://deluge-torrent.org/test_port.php?port=%s' % port
|
url = 'https://deluge-torrent.org/test_port.php?port=%s' % port
|
||||||
agent = Agent(reactor, connectTimeout=30)
|
agent = Agent(reactor, connectTimeout=30)
|
||||||
d = agent.request(
|
d = agent.request(b'GET', url.encode())
|
||||||
b'GET',
|
|
||||||
url.encode('utf-8'),
|
|
||||||
)
|
|
||||||
|
|
||||||
def on_get_page(response):
|
def on_get_page(body):
|
||||||
d = readBody(response)
|
|
||||||
d.addCallback(on_read_body)
|
|
||||||
return d
|
|
||||||
|
|
||||||
def on_read_body(body):
|
|
||||||
return bool(int(body))
|
return bool(int(body))
|
||||||
|
|
||||||
def on_error(failure):
|
def on_error(failure):
|
||||||
log.warning('Error testing listen port: %s', 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)
|
d.addErrback(on_error)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue