diff options
author | Matt Martz <matt@sivel.net> | 2019-02-19 16:56:26 -0600 |
---|---|---|
committer | Matt Martz <matt@sivel.net> | 2019-02-19 16:56:26 -0600 |
commit | 217ce8eff1a1ce307b047d86793a4593890cfa22 (patch) | |
tree | 8e64756b1719ab0d208d34a58926b06997174405 | |
parent | b43334f1ec7143e5ddf993a33d6a394bb4f2535d (diff) |
ssl.wrap_socket doesn't support server_hostname. See #572
-rwxr-xr-x | speedtest.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/speedtest.py b/speedtest.py index ff0eabf..3f58e6f 100755 --- a/speedtest.py +++ b/speedtest.py @@ -435,14 +435,18 @@ if HTTPSConnection: SpeedtestHTTPConnection.connect(self) - kwargs = {} if ssl: - if hasattr(ssl, 'SSLContext'): - kwargs['server_hostname'] = self.host try: + kwargs = {} + if hasattr(ssl, 'SSLContext'): + kwargs['server_hostname'] = self.host self.sock = self._context.wrap_socket(self.sock, **kwargs) 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): |