@@ -495,14 +495,6 @@ def test_start_tls_server_1(self):
495
495
496
496
server_context = test_utils .simple_server_sslcontext ()
497
497
client_context = test_utils .simple_client_sslcontext ()
498
- if (sys .platform .startswith ('freebsd' )
499
- or sys .platform .startswith ('win' )
500
- or sys .platform .startswith ('darwin' )):
501
- # bpo-35031: Some FreeBSD and Windows buildbots fail to run this test
502
- # as the eof was not being received by the server if the payload
503
- # size is not big enough. This behaviour only appears if the
504
- # client is using TLS1.3. Also seen on macOS.
505
- client_context .options |= ssl .OP_NO_TLSv1_3
506
498
answer = None
507
499
508
500
def client (sock , addr ):
@@ -519,9 +511,10 @@ def client(sock, addr):
519
511
sock .close ()
520
512
521
513
class ServerProto (asyncio .Protocol ):
522
- def __init__ (self , on_con , on_con_lost ):
514
+ def __init__ (self , on_con , on_con_lost , on_got_hello ):
523
515
self .on_con = on_con
524
516
self .on_con_lost = on_con_lost
517
+ self .on_got_hello = on_got_hello
525
518
self .data = b''
526
519
self .transport = None
527
520
@@ -535,7 +528,7 @@ def replace_transport(self, tr):
535
528
def data_received (self , data ):
536
529
self .data += data
537
530
if len (self .data ) >= len (HELLO_MSG ):
538
- self .transport . write ( ANSWER )
531
+ self .on_got_hello . set_result ( None )
539
532
540
533
def connection_lost (self , exc ):
541
534
self .transport = None
@@ -544,7 +537,7 @@ def connection_lost(self, exc):
544
537
else :
545
538
self .on_con_lost .set_exception (exc )
546
539
547
- async def main (proto , on_con , on_con_lost ):
540
+ async def main (proto , on_con , on_con_lost , on_got_hello ):
548
541
tr = await on_con
549
542
tr .write (HELLO_MSG )
550
543
@@ -554,17 +547,20 @@ async def main(proto, on_con, on_con_lost):
554
547
tr , proto , server_context ,
555
548
server_side = True ,
556
549
ssl_handshake_timeout = self .TIMEOUT )
557
-
558
550
proto .replace_transport (new_tr )
559
551
552
+ await on_got_hello
553
+ new_tr .write (ANSWER )
554
+
560
555
await on_con_lost
561
556
self .assertEqual (proto .data , HELLO_MSG )
562
557
new_tr .close ()
563
558
564
559
async def run_main ():
565
560
on_con = self .loop .create_future ()
566
561
on_con_lost = self .loop .create_future ()
567
- proto = ServerProto (on_con , on_con_lost )
562
+ on_got_hello = self .loop .create_future ()
563
+ proto = ServerProto (on_con , on_con_lost , on_got_hello )
568
564
569
565
server = await self .loop .create_server (
570
566
lambda : proto , '127.0.0.1' , 0 )
@@ -573,7 +569,7 @@ async def run_main():
573
569
with self .tcp_client (lambda sock : client (sock , addr ),
574
570
timeout = self .TIMEOUT ):
575
571
await asyncio .wait_for (
576
- main (proto , on_con , on_con_lost ),
572
+ main (proto , on_con , on_con_lost , on_got_hello ),
577
573
loop = self .loop , timeout = self .TIMEOUT )
578
574
579
575
server .close ()
0 commit comments