Last active
August 13, 2020 18:29
-
-
Save BretFisher/e40ab371ce44b0d3821f6cc24031759f to your computer and use it in GitHub Desktop.
quickly make a local tls cert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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