Skip to content

Instantly share code, notes, and snippets.

@JoshData
Created February 24, 2019 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshData/49eff618f84ce4890697d65bcb740137 to your computer and use it in GitHub Desktop.
Save JoshData/49eff618f84ce4890697d65bcb740137 to your computer and use it in GitHub Desktop.
self-signed TLS/SSL certificate one-liner bash script
mkdir -p /etc/ssl/local \
&& (umask 077; openssl genrsa -out /etc/ssl/local/ssl_certificate.key 2048) \
&& openssl req -new -key /etc/ssl/local/ssl_certificate.key -out temp.csr -sha256 -subj "/CN=$HOSTNAME" \
&& openssl x509 -req -days 365 -in temp.csr -signkey /etc/ssl/local/ssl_certificate.key -out /etc/ssl/local/ssl_certificate.crt \
&& rm -f temp.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment