Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socat - how to listen on non-ssl TCP and forward to ssl TCP endpoint?

Tags:

tcp

ssl

socat

I have seen an example of using socat to accept ssl TCP traffic and forward the traffic to a non-ssl host:

socat TCP-LISTEN:443,reuseaddr,fork "^OPENSSL-SERVER,cert=server.pem | TCP:somehost:80"

Is it possible to do the opposite? I.e. I have a remote host that is ssl enabled and requires a client certificate, but my client is only able to connect via non-ssl connections.

I understand the security implications of this approach.

like image 743
Chris Snow Avatar asked Sep 05 '17 08:09

Chris Snow


People also ask

What is Reuseaddr in socat?

If the file does not exist, socat creates it. The option reuseaddr allows an immediate restart of the server process.

What is netcat and socat?

Netcat and Socat allows you to pass simple messages between computers interactively over the network. The below setup will allow both client and server to send data to the other party.

What is socat in cyber security?

Socat is a multi-purpose relay tool, which means it is a more comprehensive tool than netcat. Netcat's design allows it to be a simple TCP and UDP client or server, while socat is more of a feature-rich proxy and multi-directional data transfer tool that supports multiple options and methods of invocation.


1 Answers

The answer for me was:

$ socat TCP-LISTEN:51000,fork,reuseaddr OPENSSL:remotehost:51000,cafile=certificate.pem,verify=0

The certificate didn't match the hostname so I had to switch off verification (verify=0)

like image 145
Chris Snow Avatar answered Sep 27 '22 20:09

Chris Snow