]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 19509: Don't call match_hostname() twice in http.client.
authorChristian Heimes <christian@cheimes.de>
Thu, 5 Dec 2013 06:51:17 +0000 (07:51 +0100)
committerChristian Heimes <christian@cheimes.de>
Thu, 5 Dec 2013 06:51:17 +0000 (07:51 +0100)
Lib/http/client.py

index 5c52ba349ac022a157bcbee73bf8cdd2b9e39d2f..56f548a1a7e04efa964d54f557a439dd75323d85 100644 (file)
@@ -1204,13 +1204,13 @@ else:
             server_hostname = self.host if ssl.HAS_SNI else None
             self.sock = self._context.wrap_socket(sock,
                                                   server_hostname=server_hostname)
-            try:
-                if self._check_hostname:
+            if not self._context.check_hostname and self._check_hostname:
+                try:
                     ssl.match_hostname(self.sock.getpeercert(), self.host)
-            except Exception:
-                self.sock.shutdown(socket.SHUT_RDWR)
-                self.sock.close()
-                raise
+                except Exception:
+                    self.sock.shutdown(socket.SHUT_RDWR)
+                    self.sock.close()
+                    raise
 
     __all__.append("HTTPSConnection")