Skip to content

Instantly share code, notes, and snippets.

@rdkls
Created August 31, 2018 08:26
Show Gist options
  • Save rdkls/60f56f9e6c0cedd38e7b20374a31f40d to your computer and use it in GitHub Desktop.
Save rdkls/60f56f9e6c0cedd38e7b20374a31f40d to your computer and use it in GitHub Desktop.
ssl proxy to plain tcp
#!/usr/bin/fish
set FILENAME host
set SRC_PORT 4433
set DST_PORT 8052
set DST_HOST 127.0.0.1
openssl genrsa -out $FILENAME.key
openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt -subj "/C=AU/ST=Zuid Holland/L=Rotterdam/O=Sparkling Network/OU=IT Department/CN=ssl.localhost.org"
cat $FILENAME.key $FILENAME.crt >$FILENAME.pem
chmod 600 $FILENAME.key $FILENAME.pem
echo "Listening on $SRC_PORT ..."
socat openssl-listen:$SRC_PORT,fork,reuseaddr,verify=0,cert=(pwd)/$FILENAME.pem TCP:$DST_HOST:$DST_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment