Issue #19509: Don't close the socket in do_handshake() when hostname verification fails.

This commit is contained in:
Christian Heimes 2013-12-04 20:46:20 +01:00
parent 31d83228c2
commit 1da3ba8697

View File

@ -764,15 +764,10 @@ class SSLSocket(socket):
self.settimeout(timeout)
if self.context.check_hostname:
try:
if not self.server_hostname:
raise ValueError("check_hostname needs server_hostname "
"argument")
match_hostname(self.getpeercert(), self.server_hostname)
except Exception:
self.shutdown(_SHUT_RDWR)
self.close()
raise
if not self.server_hostname:
raise ValueError("check_hostname needs server_hostname "
"argument")
match_hostname(self.getpeercert(), self.server_hostname)
def _real_connect(self, addr, connect_ex):
if self.server_side: