Commit 1da3ba86 authored by Christian Heimes's avatar Christian Heimes

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

parent 31d83228
......@@ -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:
......
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