Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # usage: mk-self-ssl <foo> [n days]
- # first variable, file name, is required
- # second variable, number of days, is optional
- umask 277
- OPENSSL=/usr/bin/openssl
- if [ -z $1 ]; then
- echo -e "\nMissing file name\n"
- elif [ -z $2 ]; then
- # Generate private key and certificate signing request
- $OPENSSL genrsa -out $1.key 2048
- $OPENSSL req -new -key $1.key -out $1.csr
- # Generate SSL certificate
- $OPENSSL x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
- else
- # Generate private key and certificate signing request
- $OPENSSL genrsa -out $1.key 2048
- $OPENSSL req -new -key $1.key -out $1.csr
- # Generate SSL certificate
- $OPENSSL x509 -req -days $2 -in $1.csr -signkey $1.key -out $1.crt
- fi
Advertisement
Add Comment
Please, Sign In to add comment