@@ -499,10 +499,10 @@ def connect():
499499 connection = connect ()
500500 try :
501501 connection .handshakeClientCert (settings = settings )
502- assert ( False )
502+ assert False
503503 except TLSLocalAlert as alert :
504504 if alert .description != AlertDescription .illegal_parameter :
505- raise
505+ raise
506506 connection .close ()
507507 else :
508508 test_no += 1
@@ -707,6 +707,43 @@ def connect():
707707
708708 test_no += 1
709709
710+ print ("Test {0} - good mutual X.509, PHA, TLSv1.3" .format (test_no ))
711+ synchro .recv (1 )
712+ connection = connect ()
713+ settings = HandshakeSettings ()
714+ settings .minVersion = (3 , 4 )
715+ settings .maxVersion = (3 , 4 )
716+ connection .handshakeClientCert (x509Chain , x509Key , settings = settings )
717+ synchro .recv (1 )
718+ b = connection .read (0 , 0 )
719+ assert b == b''
720+ testConnClient (connection )
721+ assert (isinstance (connection .session .serverCertChain , X509CertChain ))
722+ connection .close ()
723+
724+ test_no += 1
725+
726+ print ("Test {0} - mutual X.509, PHA, no client cert, TLSv1.3" .format (test_no ))
727+ synchro .recv (1 )
728+ connection = connect ()
729+ settings = HandshakeSettings ()
730+ settings .minVersion = (3 , 4 )
731+ settings .maxVersion = (3 , 4 )
732+ connection .handshakeClientCert (X509CertChain (), x509Key , settings = settings )
733+ synchro .recv (1 )
734+ b = connection .read (0 , 0 )
735+ assert b == b''
736+ try :
737+ connection .read (0 , 0 )
738+ assert False
739+ except TLSRemoteAlert as e :
740+ assert e .description == AlertDescription .certificate_required
741+ assert "certificate_required" in str (e ), str (e )
742+
743+ connection .close ()
744+
745+ test_no += 1
746+
710747 print ("Test {0} - good mutual X.509, TLSv1.1" .format (test_no ))
711748 synchro .recv (1 )
712749 connection = connect ()
@@ -784,7 +821,7 @@ def connect():
784821 connection .handshakeClientSRP ("test" , "garbage" ,
785822 serverName = address [0 ],
786823 session = session , settings = settings )
787- assert ( False )
824+ assert False
788825 except TLSRemoteAlert as alert :
789826 if alert .description != AlertDescription .bad_record_mac :
790827 raise
@@ -1014,7 +1051,7 @@ def connect():
10141051 settings .maxVersion = (3 , 2 )
10151052 try :
10161053 connection .handshakeClientCert (settings = settings )
1017- assert ()
1054+ assert False
10181055 except TLSRemoteAlert as alert :
10191056 if alert .description != AlertDescription .inappropriate_fallback :
10201057 raise
@@ -1110,6 +1147,7 @@ def connect():
11101147 try :
11111148 connection .handshakeClientCert (serverName = address [0 ], session = session ,
11121149 settings = settings )
1150+ assert False
11131151 except TLSRemoteAlert as e :
11141152 assert (str (e ) == "illegal_parameter" )
11151153 else :
@@ -1344,7 +1382,8 @@ def heartbeat_response_check(message):
13441382
13451383 print ("Test {0}: POP3 good" .format (test_no ))
13461384 except (socket .error , socket .timeout ) as e :
1347- print ("Non-critical error: socket error trying to reach internet server: " , e )
1385+ print ("Non-critical error: socket error trying to reach internet "
1386+ "server: " , e )
13481387
13491388 synchro .close ()
13501389
@@ -1603,6 +1642,7 @@ def connect():
16031642 try :
16041643 connection .handshakeServer (certChain = x509ecdsaChain ,
16051644 privateKey = x509ecdsaKey , settings = settings )
1645+ assert False
16061646 except TLSRemoteAlert as e :
16071647 assert "handshake_failure" in str (e )
16081648 connection .close ()
@@ -1634,6 +1674,7 @@ def connect():
16341674 try :
16351675 connection .handshakeServer (certChain = x509ecdsaChain ,
16361676 privateKey = x509ecdsaKey , settings = settings )
1677+ assert False
16371678 except TLSLocalAlert as e :
16381679 assert "No common signature algorithms" in str (e )
16391680 connection .close ()
@@ -1740,7 +1781,7 @@ def connect():
17401781 try :
17411782 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
17421783 tacks = [tackUnrelated ], settings = settings )
1743- assert ( False )
1784+ assert False
17441785 except TLSRemoteAlert as alert :
17451786 if alert .description != AlertDescription .illegal_parameter :
17461787 raise
@@ -1934,6 +1975,52 @@ def connect():
19341975
19351976 test_no += 1
19361977
1978+ print ("Test {0} - good mutual X.509, PHA, TLSv1.3" .format (test_no ))
1979+ synchro .send (b'R' )
1980+ connection = connect ()
1981+ settings = HandshakeSettings ()
1982+ settings .minVersion = (3 , 4 )
1983+ settings .maxVersion = (3 , 4 )
1984+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
1985+ settings = settings )
1986+ assert connection .session .clientCertChain is None
1987+ for result in connection .request_post_handshake_auth (settings ):
1988+ assert result in (0 , 1 )
1989+ synchro .send (b'R' )
1990+ testConnServer (connection )
1991+
1992+ assert connection .session .clientCertChain is not None
1993+ assert isinstance (connection .session .clientCertChain , X509CertChain )
1994+ connection .close ()
1995+
1996+ test_no += 1
1997+
1998+ print ("Test {0} - mutual X.509, PHA, no client cert, TLSv1.3" .format (test_no ))
1999+ synchro .send (b'R' )
2000+ connection = connect ()
2001+ settings = HandshakeSettings ()
2002+ settings .minVersion = (3 , 4 )
2003+ settings .maxVersion = (3 , 4 )
2004+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
2005+ settings = settings )
2006+ connection .client_cert_required = True
2007+ assert connection .session .clientCertChain is None
2008+ for result in connection .request_post_handshake_auth (settings ):
2009+ assert result in (0 , 1 )
2010+ synchro .send (b'R' )
2011+ try :
2012+ testConnServer (connection )
2013+ assert False
2014+ except TLSLocalAlert as e :
2015+ assert "Client did not provide a certificate in post-handshake" in \
2016+ str (e )
2017+ assert e .description == AlertDescription .certificate_required
2018+
2019+ assert connection .session .clientCertChain is None
2020+ connection .close ()
2021+
2022+ test_no += 1
2023+
19372024 print ("Test {0} - good mutual X.509, TLSv1.1" .format (test_no ))
19382025 synchro .send (b'R' )
19392026 connection = connect ()
@@ -1995,13 +2082,14 @@ def connect():
19952082 synchro .send (b'R' )
19962083 try :
19972084 connection .read (min = 1 , max = 1 )
1998- assert () #Client is going to close the socket without a close_notify
2085+ assert False #Client is going to close the socket without a close_notify
19992086 except TLSAbruptCloseError as e :
20002087 pass
20012088 synchro .send (b'R' )
20022089 connection = connect ()
20032090 try :
20042091 connection .handshakeServer (verifierDB = verifierDB , sessionCache = sessionCache )
2092+ assert False
20052093 except TLSLocalAlert as alert :
20062094 if alert .description != AlertDescription .bad_record_mac :
20072095 raise
@@ -2210,7 +2298,7 @@ def server_bind(self):
22102298 try :
22112299 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
22122300 settings = settings )
2213- assert ()
2301+ assert False
22142302 except TLSLocalAlert as alert :
22152303 if alert .description != AlertDescription .inappropriate_fallback :
22162304 raise
@@ -2273,6 +2361,7 @@ def server_bind(self):
22732361 try :
22742362 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
22752363 sessionCache = sessionCache )
2364+ assert False
22762365 except TLSLocalAlert as e :
22772366 assert (str (e ) == "illegal_parameter" )
22782367 else :
0 commit comments