Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Created February 6, 2023 21:03
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 VirtuBox/1b3c11062f70ead9e54ac39b1d8f995e to your computer and use it in GitHub Desktop.
Save VirtuBox/1b3c11062f70ead9e54ac39b1d8f995e to your computer and use it in GitHub Desktop.
Generate Self-signed certificate
#!/usr/bin/env bash
# -------------------------------------------------------------------------
# Generate Self-signed certificate
# -------------------------------------------------------------------------
# Usage :
#
# bash selfsigned.sh <domain>
#
# -------------------------------------------------------------------------
if [ "$1" ]; then
openssl genrsa -out "$1".key 2048
openssl req -new -batch -subj /commonName="$1"/ -key "$1".key -out "$1".csr
mv "$1".key "$1".key.org
openssl rsa -in "$1".key.org -out "$1".key
rm "$1".key.org
openssl x509 -req -days 3652 -in "$1".csr -signkey "$1".key -out "$1".crt
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment