mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
asyncio: Add server_hostname as create_connection() argument, with secure default.
This commit is contained in:
parent
2b430b8720
commit
21c85a7124
4 changed files with 78 additions and 5 deletions
|
@ -573,7 +573,7 @@ class _SelectorSslTransport(_SelectorTransport):
|
|||
'server_side': server_side,
|
||||
'do_handshake_on_connect': False,
|
||||
}
|
||||
if server_hostname is not None and not server_side and ssl.HAS_SNI:
|
||||
if server_hostname and not server_side and ssl.HAS_SNI:
|
||||
wrap_kwargs['server_hostname'] = server_hostname
|
||||
sslsock = sslcontext.wrap_socket(rawsock, **wrap_kwargs)
|
||||
|
||||
|
@ -619,7 +619,7 @@ class _SelectorSslTransport(_SelectorTransport):
|
|||
|
||||
# Verify hostname if requested.
|
||||
peercert = self._sock.getpeercert()
|
||||
if (self._server_hostname is not None and
|
||||
if (self._server_hostname and
|
||||
self._sslcontext.verify_mode != ssl.CERT_NONE):
|
||||
try:
|
||||
ssl.match_hostname(peercert, self._server_hostname)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue