Skip to content

Instantly share code, notes, and snippets.

@blackknight36
Created March 17, 2020 22:27
Show Gist options
  • Save blackknight36/05a1d31d5cb5939f7076255d8d6fda1b to your computer and use it in GitHub Desktop.
Save blackknight36/05a1d31d5cb5939f7076255d8d6fda1b to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 1 ];
then echo "Please provide a host name. For example: $0 spmasv-ignap01"
exit 1
fi
hostname=$1
domain='dartcontainer.com'
ip=`dig +short $hostname.$domain`
keystore="$hostname-keystore.key"
storepass="ignition"
alias="tomcat"
rm -f $keystore
keytool -genkey -dname "CN=$hostname.$domain, OU=IT, O=Dart Container Corporation, L=Mason, ST=Michigan, C=US" -alias $alias -keyalg RSA -keysize 2048 -keystore $keystore -storepass $storepass -keypass $storepass 2>/dev/null
keytool -certreq -alias $alias -file $hostname.csr.txt -keystore $keystore -storepass $storepass -ext "SAN=dns:$hostname.$domain,dns:$hostname,ip:$ip" 2>/dev/null
keytool -import -trustcacerts -alias root -file DCIssuingCa.crt -keystore $keystore -storepass $storepass 2>/dev/null
echo "Here is your CSR: "
cat $hostname.csr.txt
echo "To verify this CSR run this command:"
echo "openssl req -in $hostname.csr.txt -noout -text"
echo "This CSR can be signed by the Dart CA at https://mas-ca02.dartcontainer.com/certsrv/certrqxt.asp"
echo "After signing import the cert with this command."
echo "keytool -import -trustcacerts -alias $alias -file $hostname.crt.txt" -keystore $keystore -storepass $storepass"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment