Reputation: 4610
I want to combine openssl
and socat
to add encryption to plain-text UDP sockets. Specifically,
My app opens an UDP socket and sends plain-text data to 127.0.0.1:8032
. I want socat to establish a DTLS session with a remote openssl server and encrypt the plain-text data sent by me app, as well as decrypt and relay back the response.
I've managed to handshake using openssl s_client
:
openssl s_client -dtls1_2 -psk <KEY> -psk_identity <ID> -connect <IP>:<PORT>
but I can't get the socat tunnel to work:
socat -x -vvvvvvv SYSTEM:'openssl s_client -dtls1_2 -psk <KEY> -psk_identity <ID> -connect <IP>:<PORT>' UDP-LISTEN:8032
It seems that socat relays the plain-text data, but
I'm not sure the handshake ever gets done, and I'm not sure socat will relay the response correctly anyway with this setup. Help?
Upvotes: 2
Views: 1363
Reputation: 4610
I managed to get it work with the following modification. Instead of -connect <IP>:<PORT>
, use -connect <IP> -port <PORT>
. Not particularily intuitive imo, but dumping the traffic with wireshark made it fairly easy to figure out. Yay wireshark.
Upvotes: 2