https from the command line - quickly set up a openssl proxy for testing


It is often useful or required to use https rather than http in order to do development browser testing.  Most modern 3rd party js libs require https origins and will just fail in browsers if not called/referenced from https rather than http.  This quick script sets uses openssl and socat to set up a quick proxy that can be redirected to your local running http server to provide an https endpoint.

The script assumes you are running in a UNIX environ


brew install socat 

sudo yum install socat 

sudo apt-get install socat 

mkdir ssl
cd ssl

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

socat -v openssl-listen:8443,cert=cert.pem,key=./key.pem,verify=0,reuseaddr,fork tcp4: