File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,5 @@ DEF LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
20
20
# The default timeout matches that of Nginx.
21
21
DEF SSL_HANDSHAKE_TIMEOUT = 60.0
22
22
# Number of seconds to wait for SSL shutdown to complete
23
- # The default timeout mimics lingering_time
24
- DEF SSL_SHUTDOWN_TIMEOUT = 30.0
23
+ DEF SSL_SHUTDOWN_TIMEOUT = 10.0
25
24
DEF SSL_READ_MAX_SIZE = 256 * 1024
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ cdef class SSLProtocol:
84
84
object _handshake_timeout_handle
85
85
object _shutdown_timeout_handle
86
86
87
+ str _ssl_version
88
+
87
89
cdef _set_app_protocol(self , app_protocol)
88
90
cdef _wakeup_waiter(self , exc = * )
89
91
cdef _get_extra_info(self , name, default = * )
Original file line number Diff line number Diff line change @@ -536,6 +536,7 @@ cdef class SSLProtocol:
536
536
cipher = sslobj.cipher(),
537
537
compression = sslobj.compression(),
538
538
ssl_object = sslobj)
539
+ self ._ssl_version = sslobj.version()
539
540
if self ._app_state == STATE_INIT:
540
541
self ._app_state = STATE_CON_MADE
541
542
self ._app_protocol.connection_made(self ._get_app_transport())
@@ -585,6 +586,9 @@ cdef class SSLProtocol:
585
586
"""
586
587
cdef:
587
588
bint close_notify = False
589
+ if self ._app_state == STATE_EOF:
590
+ # close_notify was already received
591
+ return
588
592
try :
589
593
while True :
590
594
if not self ._sslobj_read(SSL_READ_MAX_SIZE):
@@ -626,6 +630,11 @@ cdef class SSLProtocol:
626
630
self ._sslobj.unwrap()
627
631
except ssl_SSLAgainErrors as exc:
628
632
self ._process_outgoing()
633
+ if self ._ssl_version != " TLSv1.3" :
634
+ # don't wait for close_notify from the peer in TLSv1.2 or
635
+ # lower to conform with widespread implementation practice
636
+ if not self ._get_write_buffer_size():
637
+ self ._on_shutdown_complete(None )
629
638
else :
630
639
self ._process_outgoing()
631
640
if not self ._get_write_buffer_size():
You can’t perform that action at this time.
0 commit comments