mobius-software-ltd / pyton3-dtls

Datagram Transport Layer Security for Python
Apache License 2.0
6 stars 6 forks source link

Issue when trying to use in conjunction with "sslpsk" library. #6

Closed d8ahazard closed 4 years ago

d8ahazard commented 5 years ago

I'm trying to implement dtls with psk to work with the hue entertainment API. Unfortunately, I'm having some issues, and I'm not quite sure if the problem is with dtls or sslpsk.

Also openend https://github.com/drbild/sslpsk/issues/6

Process finished with exit code -1073741819 (0xC0000005)

def do_handshake(self):
    print("Handshaking with ", self.bridge_ip)
    ssl_sock = False
    psk = binascii.unhexlify(self.bridge_key)
    print("PSK", psk)
    try:
        do_patch()  # dtls library doing its thing
        print("Patched")
        host = self.bridge_ip
        port = 2100
        print("Wrapping socket")
        tcp_socket = socket(AF_INET, SOCK_DGRAM)
        tcp_socket.connect((host, port))
        ssl_sock = sslpsk.wrap_socket(tcp_socket,
                                      ssl_version=258,
                                      ciphers='PSK-AES128-GCM-SHA256',
                                      psk=psk, hint=self.user)
        print("Socket wrapped")

        msg = "ping"
        ssl_sock.sendall(msg.encode())
        msg = ssl_sock.recv(4).decode()
        print('Client received: %s' % msg)
    except Exception as e:
        print("Socket exception: ", e)
    return ssl_sock
yulianoifa-mobius commented 4 years ago

Hi The code you have provided is not related to DTLS which is working over UDP. Your code is related to TCP. You would need to view to code of both DTLS and SSLPSK libraries and modify SSLPSK according to RFC to support the UDP socket

d8ahazard commented 4 years ago

Yeah, no. It's definitely for UDP. Hue streaming.

but, hey, I appreciate you taking a year to get back to me and being completely dismissive of my request. Have a good one!