Skip to content

Commit 4bec899

Browse files
committed
Attempt to address python compatibility issues
1 parent 68122f9 commit 4bec899

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tlslite/tlsconnection.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,9 +3268,12 @@ def _serverTLS13Handshake(self, settings, clientHello, cipherSuite,
32683268
# log them if necessary
32693269
if self.sslkeylogfile:
32703270
self._log_session_keys([
3271-
('EXPORTER_SECRET', clientHello.random, exporter_master_secret),
3272-
('CLIENT_TRAFFIC_SECRET_0', clientHello.random, cl_app_traffic),
3273-
('SERVER_TRAFFIC_SECRET_0', clientHello.random, sr_app_traffic)
3271+
('EXPORTER_SECRET',
3272+
clientHello.random, exporter_master_secret),
3273+
('CLIENT_TRAFFIC_SECRET_0',
3274+
clientHello.random, cl_app_traffic),
3275+
('SERVER_TRAFFIC_SECRET_0',
3276+
clientHello.random, sr_app_traffic)
32743277
])
32753278

32763279

@@ -4999,7 +5002,10 @@ def _log_session_keys(self, keys):
49995002

50005003
with open(self.sslkeylogfile, 'a') as ssl_key_log_file:
50015004
ssl_key_log_file.writelines(
5002-
f"{label} {client_random.hex()} {secret.hex()}\n"
5005+
"{0} {1} {2}\n".format(
5006+
label,
5007+
binascii.hexlify(client_random).decode().upper(),
5008+
binascii.hexlify(secret).decode().upper())
50035009
for label, client_random, secret in keys
50045010
)
50055011

unit_tests/test_tlslite_ssl_key_log_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def validate_log_file(log_file_name, labels: Dict[str, List[str]]):
4848

4949
class TestSslKeyLogFile(unittest.TestCase):
5050
def setUp(self):
51-
self.temp_log_file = tempfile.NamedTemporaryFile(delete_on_close=False)
51+
self.temp_log_file = tempfile.NamedTemporaryFile(delete=False)
5252
os.environ['SSLKEYLOGFILE'] = self.temp_log_file.name
5353

5454
def tearDown(self):
@@ -86,7 +86,7 @@ def test_tlsv1_2(self):
8686
self.assertTrue(validate_log_file(self.temp_log_file.name, expected_labels))
8787
connection.close()
8888
except TLSRemoteAlert as alert:
89-
print(f"TLS Remote Alert: {alert}")
89+
print("TLS Remote Alert: {0}".format(alert))
9090

9191
def test_tlsv1_3(self):
9292
settings = HandshakeSettings()
@@ -105,7 +105,7 @@ def test_tlsv1_3(self):
105105
self.assertTrue(validate_log_file(self.temp_log_file.name, expected_labels))
106106
connection.close()
107107
except TLSRemoteAlert as alert:
108-
print(f"TLS Remote Alert: {alert}")
108+
print("TLS Remote Alert: {0}".format(alert))
109109

110110

111111
if __name__ == "__main__":

0 commit comments

Comments
 (0)