mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
Issue #19509: Don't close the socket in do_handshake() when hostname verification fails.
This commit is contained in:
parent
31d83228c2
commit
1da3ba8697
1 changed files with 4 additions and 9 deletions
|
@ -764,15 +764,10 @@ class SSLSocket(socket):
|
||||||
self.settimeout(timeout)
|
self.settimeout(timeout)
|
||||||
|
|
||||||
if self.context.check_hostname:
|
if self.context.check_hostname:
|
||||||
try:
|
|
||||||
if not self.server_hostname:
|
if not self.server_hostname:
|
||||||
raise ValueError("check_hostname needs server_hostname "
|
raise ValueError("check_hostname needs server_hostname "
|
||||||
"argument")
|
"argument")
|
||||||
match_hostname(self.getpeercert(), self.server_hostname)
|
match_hostname(self.getpeercert(), self.server_hostname)
|
||||||
except Exception:
|
|
||||||
self.shutdown(_SHUT_RDWR)
|
|
||||||
self.close()
|
|
||||||
raise
|
|
||||||
|
|
||||||
def _real_connect(self, addr, connect_ex):
|
def _real_connect(self, addr, connect_ex):
|
||||||
if self.server_side:
|
if self.server_side:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue