File 774544_0001-use-right-address-to-check-certificate.patch of Package python-pip.7848

diff --git a/pip/download.py b/pip/download.py
index 653495f..0e8f345 100644
--- a/pip/download.py
+++ b/pip/download.py
@@ -125,6 +125,9 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
         if getattr(self, '_tunnel_host', None):
             self.sock = sock
             self._tunnel()
+            final_host = self._tunnel_host
+        else:
+            final_host = self.host
 
         # get alternate bundle or use our included bundle
         cert_path = os.environ.get('PIP_CERT', '') or default_cert_path
@@ -136,7 +139,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
                                 ca_certs=cert_path)
 
         try:
-            match_hostname(self.sock.getpeercert(), self.host)
+            match_hostname(self.sock.getpeercert(), final_host)
         except CertificateError:
             self.sock.shutdown(socket.SHUT_RDWR)
             self.sock.close()
openSUSE Build Service is sponsored by