mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-29970: Add timeout for SSL handshake in asyncio
10 seconds by default.
This commit is contained in:
parent
4b965930e8
commit
f7686c1f55
12 changed files with 207 additions and 83 deletions
|
@ -389,11 +389,15 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
|
|||
return _ProactorSocketTransport(self, sock, protocol, waiter,
|
||||
extra, server)
|
||||
|
||||
def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None,
|
||||
*, server_side=False, server_hostname=None,
|
||||
extra=None, server=None):
|
||||
ssl_protocol = sslproto.SSLProtocol(self, protocol, sslcontext, waiter,
|
||||
server_side, server_hostname)
|
||||
def _make_ssl_transport(
|
||||
self, rawsock, protocol, sslcontext, waiter=None,
|
||||
*, server_side=False, server_hostname=None,
|
||||
extra=None, server=None,
|
||||
ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT):
|
||||
ssl_protocol = sslproto.SSLProtocol(
|
||||
self, protocol, sslcontext, waiter,
|
||||
server_side, server_hostname,
|
||||
ssl_handshake_timeout=ssl_handshake_timeout)
|
||||
_ProactorSocketTransport(self, rawsock, ssl_protocol,
|
||||
extra=extra, server=server)
|
||||
return ssl_protocol._app_transport
|
||||
|
@ -486,7 +490,8 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
|
|||
self._csock.send(b'\0')
|
||||
|
||||
def _start_serving(self, protocol_factory, sock,
|
||||
sslcontext=None, server=None, backlog=100):
|
||||
sslcontext=None, server=None, backlog=100,
|
||||
ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT):
|
||||
|
||||
def loop(f=None):
|
||||
try:
|
||||
|
@ -499,7 +504,8 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
|
|||
if sslcontext is not None:
|
||||
self._make_ssl_transport(
|
||||
conn, protocol, sslcontext, server_side=True,
|
||||
extra={'peername': addr}, server=server)
|
||||
extra={'peername': addr}, server=server,
|
||||
ssl_handshake_timeout=ssl_handshake_timeout)
|
||||
else:
|
||||
self._make_socket_transport(
|
||||
conn, protocol,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue