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


## install socat based on your Unix flavor.
## for osx
brew install socat 

## or cent/redhat
sudo yum install socat 

## or debian/ubuntu
sudo apt-get install socat 

## make a folder and dive in!
mkdir ssl
cd ssl

## Generate a fake cert (accept defualts)
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

## fire up socat 
## this assumes your dev webserver is running on localhost 8080 
socat -v openssl-listen:8443,cert=cert.pem,key=./key.pem,verify=0,reuseaddr,fork tcp4:

## browse to your new https server!

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor