Last active
May 24, 2016 18:30
-
-
Save fforbeck/f0bd936116bbc51f2ff7e9f103ad431d to your computer and use it in GitHub Desktop.
Script to generate csr, key and crt
This file contains 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
[ req ] | |
distinguished_name="req_distinguished_name" | |
prompt="no" | |
[ req_distinguished_name ] | |
C="<country>" | |
ST="<state>" | |
L="1234" | |
O="1234" | |
CN="{DOMAIN}" |
This file contains 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
#!/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