0

I have been learning, through a veil of many tears, the concepts of network programming. I started with a simple UDP client/server pair, moved to TCP, and then secured the TCP stream successfully using TLS. Now I am trying to "defeat the final boss", and secure UDP communication using DTLS.

I put together a very simple UDP client/server pair using DTLS to attempt and successfully exchange encrypted communications. Let me break down the problem into the client and server.

DTLS Client

import socket
import ssl
from dtls import do_patch
do_patch()

serverAddress, serverPort = "IP Address", 12345
addr = (serverAddress, serverPort)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
SSLSocket = ssl.wrap_socket(s, '.\key.pem', '\cert.pem', server_side=False)

SSLSocket.connect(addr)
clientMessage = bytes(('I am the UDP client').encode('utf-8'))

SSLSocket.send(clientMessage)

Client Hello is successfully seen in Wireshark using the DTLS protocol.

DTLS Server

import ssl
from socket import socket, AF_INET, SOCK_DGRAM
from dtls import do_patch
do_patch()

##### Server and Socket Parameters #####
serverAddress, serverPort = "192.168.1.158", 12345
addr = (serverAddress, serverPort)

s = socket(AF_INET, SOCK_DGRAM)
sock = ssl.wrap_socket(s, '.\key.pem', '.\cert.pem', server_side=True)
sock.bind(addr)
sock.listen(2)
clientSocket, addr = sock.accept()
print("Connection established")

Server program runs successfully, however the client does not seem to be able to connect. The server never acknowledges the Client Hello, and this is reflected by the client retransmitting its hello message at regular intervals.

I could not get a Print() statement in the server after sock.listen(2). I'm not 100% sure what this could mean. Either the server is listening and waiting, the Print() statement not executing, or something else that is not causing a runtime error.

Regardless, sock.accept() never gets reached, and the client is stuck sending Hello messages forever. I'm not sure what the issue is, and would greatly appreciate some feedback on the matter.

2
  • You may use a known working client and server and do some cross tests. Depending on your skill, Eclipse/tinydtls (C) or Eclipse/Californium (Java) do a good job. You may also try to connect your client against the Californium sandbox, github.com/eclipse-californium/californium#interop-server. Just to see the DTLS handshake, no need for CoAP: Mar 19 at 17:58
  • Client : "IP Address", 12345 and what does Wireshark show as destination of the Client_Hello? Mar 19 at 18:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.