Last active
November 13, 2022 13:05
-
-
Save praseodym/8186510 to your computer and use it in GitHub Desktop.
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 | |
# csr.sh: Certificate Signing Request Generator | |
set -e | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 hostname [alt.hostname1] [alt.hostname2]" | |
exit 1 | |
fi | |
LASTUMASK=`umask` | |
umask 077 | |
HOST=$1 | |
SAN="DNS:${HOST}" | |
shift | |
while [ -n "$1" ]; do | |
SAN="${SAN},DNS:$1" | |
shift | |
done | |
openssl req -new -newkey rsa:2048 -keyout ${HOST}.key -sha512 -nodes -batch -reqexts SAN \ | |
-subj "/C=NL/ST=Zuid-Holland/L=Delft/O=W.I.S.V. \'Christiaan Huygens\'/OU=Beheer/CN=${HOST}/[email protected]" \ | |
-config /dev/stdin > ${HOST}.csr <<EOF | |
$(cat "$(openssl version -d | cut -d\" -f2)/openssl.cnf") | |
[SAN] | |
subjectAltName=$SAN | |
EOF | |
umask $LASTUMASK | |
set -x | |
openssl req -text -noout -verify -in ${HOST}.csr | |
cat ${HOST}.csr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment