diff --git a/setup/linux-installer.py b/setup/linux-installer.py index 755e56f05f..b17de36bc5 100644 --- a/setup/linux-installer.py +++ b/setup/linux-installer.py @@ -441,11 +441,16 @@ def match_hostname(cert, hostname): if _dnsname_match(value, hostname): return dnsnames.append(value) + if len(dnsnames) > 1: raise CertificateError("hostname %r " "doesn't match either of %s" % (hostname, ', '.join(map(repr, dnsnames)))) elif len(dnsnames) == 1: + # python 2.6 does not read subjectAltName, so we do the best we can + if sys.version_info[:2] == (2, 6): + if dnsnames[0] == 'calibre-ebook.com': + return raise CertificateError("hostname %r " "doesn't match %r" % (hostname, dnsnames[0])) @@ -474,8 +479,12 @@ else: certificate, both that it is valid and that its declared hostnames match the hostname we are connecting to.""" - sock = socket.create_connection((self.host, self.port), + if hasattr(self, 'source_address'): + sock = socket.create_connection((self.host, self.port), self.timeout, self.source_address) + else: + # python 2.6 has no source_address + sock = socket.create_connection((self.host, self.port), self.timeout) if self._tunnel_host: self.sock = sock self._tunnel()