Skip to content

Instantly share code, notes, and snippets.

@daggerhart
Last active September 18, 2019 10:43
Show Gist options
  • Save daggerhart/a416d27fa699fbb4108ba09c7dd82b4b to your computer and use it in GitHub Desktop.
Save daggerhart/a416d27fa699fbb4108ba09c7dd82b4b to your computer and use it in GitHub Desktop.
Simple script to generate a certificate used for local development on OSX
#!/bin/bash
read -p 'Domain: ' DOMAIN
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout "$DOMAIN".key \
-new \
-out $DOMAIN.crt \
-subj /CN="$DOMAIN" \
-reqexts SAN \
-extensions SAN \
-config <(cat /System/Library/OpenSSL/openssl.cnf \
<(printf "[SAN]\nsubjectAltName=DNS:$DOMAIN")) \
-sha256 \
-days 720
@daggerhart
Copy link
Author

How to:

  1. ./_genCert.sh
  2. (type in your desired domain)
  3. Open finder and double click the new .crt file. It should open in Keychain.
  4. Double click the new certificate, expand "Trust", set to "Always Trust"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment