mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-01-05 19:40:11 +01:00
ssl.wrap_socket doesn't support server_hostname. See #572
This commit is contained in:
12
speedtest.py
12
speedtest.py
@@ -435,14 +435,18 @@ if HTTPSConnection:
|
|||||||
|
|
||||||
SpeedtestHTTPConnection.connect(self)
|
SpeedtestHTTPConnection.connect(self)
|
||||||
|
|
||||||
kwargs = {}
|
|
||||||
if ssl:
|
if ssl:
|
||||||
if hasattr(ssl, 'SSLContext'):
|
|
||||||
kwargs['server_hostname'] = self.host
|
|
||||||
try:
|
try:
|
||||||
|
kwargs = {}
|
||||||
|
if hasattr(ssl, 'SSLContext'):
|
||||||
|
kwargs['server_hostname'] = self.host
|
||||||
self.sock = self._context.wrap_socket(self.sock, **kwargs)
|
self.sock = self._context.wrap_socket(self.sock, **kwargs)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.sock = ssl.wrap_socket(self.sock, **kwargs)
|
self.sock = ssl.wrap_socket(self.sock)
|
||||||
|
try:
|
||||||
|
self.sock.server_hostname = self.host
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _build_connection(connection, source_address, timeout, context=None):
|
def _build_connection(connection, source_address, timeout, context=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user