Skip to content

Instantly share code, notes, and snippets.

@willscripted
Last active November 25, 2015 12:38
Show Gist options
  • Save willscripted/6e13aee9e5f89cbce7f9 to your computer and use it in GitHub Desktop.
Save willscripted/6e13aee9e5f89cbce7f9 to your computer and use it in GitHub Desktop.
One-liner for making self-signed certs. `mkcert <domain-name>`. Just add this script to your $PATH
#!/usr/bin/env bash
mkdir -p /tmp/mkcert
openssl genrsa -des3 -passout pass:x -out /tmp/mkcert/server.pass.key 2048
openssl rsa -passin pass:x -in /tmp/mkcert/server.pass.key -out /tmp/mkcert/server.key
rm /tmp/mkcert/server.pass.key
openssl req -new -key /tmp/mkcert/server.key -out /tmp/mkcert/server.csr \
-subj "/C=US/ST=Massachusettes/L=Boston/O=Me/OU=Department of Departments/CN=$1"
openssl x509 -req -days 365 -in /tmp/mkcert/server.csr -signkey /tmp/mkcert/server.key -out /tmp/mkcert/server.crt
mv /tmp/mkcert/* `pwd`
rm -rf /tmp/mkcert/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment