meesteridle icon

mk-self-ssl

meesteridle | PRO | 06/19/15 10:39:28 PM UTC | 0 ⭐ | 211 👁️ | Never ⏰ | []
Bash |

730 B

|

None

|

0 👍

/

0 👎

#!/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

Comments