-
-
Save BitbeyHub/42606345736d2e257817b87239832446 to your computer and use it in GitHub Desktop.
SSL server/client in socat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| if [ $# -eq 0 ];then | |
| echo "Supply client|server" | |
| exit 1 | |
| fi | |
| FILENAME=$1 | |
| openssl genrsa -out $FILENAME.key 1024 | |
| # During certificate creation when prompted for | |
| # `Common Name (eg, your name or your server's hostname) []` you should enter localhost | |
| openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt | |
| cat $FILENAME.key $FILENAME.crt >$FILENAME.pem | |
| chmod 600 $FILENAME.key $FILENAME.pem | |
| # Server | |
| # socat openssl-listen:14344,reuseaddr,cert=./server.pem,cafile=./client.crt echo | |
| # Client | |
| # socat stdio openssl-connect:localhost:14344,cert=./client.pem,cafile=./server.crt | |
| # Verification | |
| # You should see ESTABLISHED connection | |
| # netstat -ant | grep 14344 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment