Skip to content

Instantly share code, notes, and snippets.

@fforbeck
Last active May 24, 2016 18:30
Show Gist options
  • Save fforbeck/f0bd936116bbc51f2ff7e9f103ad431d to your computer and use it in GitHub Desktop.
Save fforbeck/f0bd936116bbc51f2ff7e9f103ad431d to your computer and use it in GitHub Desktop.
Script to generate csr, key and crt
[ req ]
distinguished_name="req_distinguished_name"
prompt="no"
[ req_distinguished_name ]
C="<country>"
ST="<state>"
L="1234"
O="1234"
CN="{DOMAIN}"
#!/bin/bash
KEY_NAME=$1
DOMAIN=$2
# Fetch CSR Conf
cat csr_conf.template | sed s/{DOMAIN}/${DOMAIN}/ > ${KEY_NAME}_csr.conf
# Generate key and csr
openssl req -config ${KEY_NAME}_csr.conf -new -newkey rsa:2048 -nodes -keyout ${KEY_NAME}.key -out ${KEY_NAME}.csr
# Self sign cert
openssl req -x509 -nodes -days 365 -key ${KEY_NAME}.key -in ${KEY_NAME}.csr -out ${KEY_NAME}.crt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment