Skip to content

Instantly share code, notes, and snippets.

@BretFisher
Last active August 13, 2020 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BretFisher/e40ab371ce44b0d3821f6cc24031759f to your computer and use it in GitHub Desktop.
Save BretFisher/e40ab371ce44b0d3821f6cc24031759f to your computer and use it in GitHub Desktop.
quickly make a local tls cert
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DOMAIN_NAME=$1
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout "$DOMAIN_NAME.key" \
-new \
-out "$DOMAIN_NAME.crt" \
-subj "/CN=*.$DOMAIN_NAME" \
-reqexts SAN \
-extensions SAN \
-config <(cat /etc/ssl/openssl.cnf \
<(printf "[SAN]\nsubjectAltName=DNS:*.%s, DNS:%s" "$DOMAIN_NAME" "$DOMAIN_NAME")) \
-sha256 \
-days 3650
cat "$DOMAIN_NAME.crt" "$DOMAIN_NAME.key" \
| tee "$DOMAIN_NAME.pem"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment