Skip to content

Instantly share code, notes, and snippets.

@JoshData
Created February 24, 2019 17:51
Show Gist options
  • 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