Skip to content

Instantly share code, notes, and snippets.

@maruware
Last active March 23, 2020 06:44
Show Gist options
  • Save maruware/c1acc8d81a5c5b152cc6ddaae196078c to your computer and use it in GitHub Desktop.
Save maruware/c1acc8d81a5c5b152cc6ddaae196078c to your computer and use it in GitHub Desktop.
Generate TSL certificate
#!/bin/bash
CN=${CN:-example.com}
NAME=${NAME:-example}
DST=${DST:-.}
echo "CN=$CN, NAME=$NAME, DST=$DST"
openssl req -nodes -newkey rsa:2048 -subj "/CN=$CN/O=$NAME" \
-keyout $DST/$NAME.key -out $DST/$NAME.csr && \
openssl x509 -req -signkey $DST/$NAME.key -in $DST/$NAME.csr -out $DST/$NAME.crt && \
rm -f $DST/$NAME.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment