Template:Makecert.sh
Jump to navigation
Jump to search
Linux script to generate custom self signed certificate
makecert.sh:
#!/bin/sh # ./makecert.sh <domain> if [ "$1" = "" ] ; then echo "Error: Usage: $0 <domain> \"[cert-domain]\"" exit 1 fi DOMAIN=$1 if [ "$2" != "" ] ; then CERTDOMAIN=$2 else CERTDOMAIN=$1 fi echo "Creating SSL cert for $DOMAIN ($CERTDOMAIN)" mkdir $1 cd $1 # openssl req -config ../openssl.cnf -new -out $DOMAIN.csr # openssl req -new -out $DOMAIN.csr openssl req -new -out $DOMAIN.csr -passout pass:test <<EOF US Utah Salt Lake City $DOMAIN $DOMAIN $CERTDOMAIN EOF # openssl rsa -in privkey.pem -out $DOMAIN.key openssl rsa -in privkey.pem -out $DOMAIN.key -passin pass:test openssl x509 -in $DOMAIN.csr -out $DOMAIN.cert -req -signkey $DOMAIN.key -days 1825 # 5 years openssl x509 -in $DOMAIN.cert -out $DOMAIN.der.crt -outform DER # optional cat $DOMAIN.key $DOMAIN.cert > $DOMAIN.pem # FYI, pem for chain would be 'key, cert, chain > pem'
See openssl.cnf