mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
Issue #19509: Don't close the socket in do_handshake() when hostname verification fails.
This commit is contained in:
parent
31d83228c2
commit
1da3ba8697
13
Lib/ssl.py
13
Lib/ssl.py
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user