Skip to content

Commit

Permalink
fixed example code issue (for Linux) #7
Browse files Browse the repository at this point in the history
  • Loading branch information
aiantsen committed Apr 8, 2024
1 parent c7cd198 commit 84d525b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/get/synchronous/psk_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/sender/synchronous/psk_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions examples/sender/synchronous/psk_wrapper_from_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 84d525b

Please sign in to comment.