From 84d525bbbc72c66a6a3a08856d52d31e211c5c62 Mon Sep 17 00:00:00 2001 From: Aleksandr Iantsen Date: Mon, 8 Apr 2024 08:36:01 +0300 Subject: [PATCH] fixed example code issue (for Linux) #7 --- examples/get/synchronous/psk_wrapper.py | 2 +- examples/sender/synchronous/psk_wrapper.py | 2 +- examples/sender/synchronous/psk_wrapper_from_config.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/get/synchronous/psk_wrapper.py b/examples/get/synchronous/psk_wrapper.py index 49fb609..8551088 100644 --- a/examples/get/synchronous/psk_wrapper.py +++ b/examples/get/synchronous/psk_wrapper.py @@ -17,7 +17,7 @@ # PSK wrapper function for SSL connection def psk_wrapper(sock): # Pre-Shared Key (PSK) and PSK Identity - psk = b'608b0a0049d41fdb35a824ef0a227f24e5099c60aa935e803370a961c937d6f7' + psk = bytes.fromhex('608b0a0049d41fdb35a824ef0a227f24e5099c60aa935e803370a961c937d6f7') psk_identity = b'PSKID' # Wrap the socket using sslpsk to establish an SSL connection with PSK diff --git a/examples/sender/synchronous/psk_wrapper.py b/examples/sender/synchronous/psk_wrapper.py index 1851bbe..9dea96e 100644 --- a/examples/sender/synchronous/psk_wrapper.py +++ b/examples/sender/synchronous/psk_wrapper.py @@ -17,7 +17,7 @@ # PSK wrapper function for SSL connection def psk_wrapper(sock, tls): # Pre-Shared Key (PSK) and PSK Identity - psk = b'608b0a0049d41fdb35a824ef0a227f24e5099c60aa935e803370a961c937d6f7' + psk = bytes.fromhex('608b0a0049d41fdb35a824ef0a227f24e5099c60aa935e803370a961c937d6f7') psk_identity = b'PSKID' return sslpsk.wrap_socket( diff --git a/examples/sender/synchronous/psk_wrapper_from_config.py b/examples/sender/synchronous/psk_wrapper_from_config.py index 66f62a7..4ff8cef 100644 --- a/examples/sender/synchronous/psk_wrapper_from_config.py +++ b/examples/sender/synchronous/psk_wrapper_from_config.py @@ -15,15 +15,15 @@ # PSK wrapper function for SSL connection -def psk_wrapper(sock, tls): +def psk_wrapper(sock, config): psk = None - psk_identity = tls.get('tlspskidentity') - psk_file = tls.get('tlspskfile') + psk_identity = config.get('tlspskidentity').encode('utf-8') + psk_file = config.get('tlspskfile') # Read PSK from file if specified if psk_file: with open(psk_file, encoding='utf-8') as f: - psk = f.read() + psk = bytes.fromhex(f.read()) # Check if both PSK and PSK identity are available if psk and psk_identity: