Commit 594ac54e authored by Christian Heimes's avatar Christian Heimes

Issue 19509: Don't call match_hostname() twice in http.client.

parent ca90fe6c
...@@ -1204,13 +1204,13 @@ else: ...@@ -1204,13 +1204,13 @@ else:
server_hostname = self.host if ssl.HAS_SNI else None server_hostname = self.host if ssl.HAS_SNI else None
self.sock = self._context.wrap_socket(sock, self.sock = self._context.wrap_socket(sock,
server_hostname=server_hostname) server_hostname=server_hostname)
try: if not self._context.check_hostname and self._check_hostname:
if self._check_hostname: try:
ssl.match_hostname(self.sock.getpeercert(), self.host) ssl.match_hostname(self.sock.getpeercert(), self.host)
except Exception: except Exception:
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
raise raise
__all__.append("HTTPSConnection") __all__.append("HTTPSConnection")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment