Skip to content

Commit f119252

Browse files
authored
Merge pull request #380 from tomato42/pha-determinism
fix PHA with KeyUpdate with HTTP
2 parents ed727a7 + ee4695c commit f119252

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/tlstest.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,25 @@ def connect():
723723

724724
test_no += 1
725725

726+
print("Test {0} - good mutual X.509, PHA and KeyUpdate, 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(x509Chain, x509Key, settings=settings)
733+
for result in connection.send_keyupdate_request(
734+
KeyUpdateMessageType.update_requested):
735+
assert result in (0, 1)
736+
synchro.recv(1)
737+
b = connection.read(0, 0)
738+
assert b == b''
739+
testConnClient(connection)
740+
assert(isinstance(connection.session.serverCertChain, X509CertChain))
741+
connection.close()
742+
743+
test_no += 1
744+
726745
print("Test {0} - mutual X.509, PHA, no client cert, TLSv1.3".format(test_no))
727746
synchro.recv(1)
728747
connection = connect()
@@ -1995,6 +2014,27 @@ def connect():
19952014

19962015
test_no += 1
19972016

2017+
print("Test {0} - good mutual X.509, PHA and KeyUpdate, TLSv1.3".format(test_no))
2018+
synchro.send(b'R')
2019+
connection = connect()
2020+
settings = HandshakeSettings()
2021+
settings.minVersion = (3, 4)
2022+
settings.maxVersion = (3, 4)
2023+
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key,
2024+
settings=settings)
2025+
assert connection.session.clientCertChain is None
2026+
for result in connection.request_post_handshake_auth(settings):
2027+
assert result in (0, 1)
2028+
synchro.send(b'R')
2029+
assert connection.read(0, 0) == b''
2030+
assert connection.session.clientCertChain is not None
2031+
assert isinstance(connection.session.clientCertChain, X509CertChain)
2032+
testConnServer(connection)
2033+
2034+
connection.close()
2035+
2036+
test_no += 1
2037+
19982038
print("Test {0} - mutual X.509, PHA, no client cert, TLSv1.3".format(test_no))
19992039
synchro.send(b'R')
20002040
connection = connect()

tlslite/tlsrecordlayer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ def readAsync(self, max=None, min=1):
357357
elif isinstance(result, KeyUpdate):
358358
for result in self._handle_keyupdate_request(result):
359359
yield result
360+
# KeyUpdate messages are not solicited, while call with
361+
# min==0 are done to perform PHA
362+
try_once = True
360363
elif isinstance(result, Certificate):
361364
for result in self._handle_srv_pha(result):
362365
yield result

0 commit comments

Comments
 (0)