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