Generating SSL certificates using OpenSSL
Posted: 10 May 2010, 12:56pm - Monday

Based on Centos Wiki on HowTo SSL - http://wiki.centos.org/HowTos/Https I simplified the procedure to create a bash script. Here's the code;

#!/bin/bash
umask 077

echo ""
if [ $# -eq 0 ] ; then
 echo $"Usage: `basename $0` <DOMAIN_NAME> [...]"
 echo ""
 exit 0
fi

for target in $@ ; do

 keyFile=${target}.key
 crtFile=${target}.crt
 csrFile=${target}.csr

 echo $keyFile
 echo $crtFile
 echo $csrFile

 # Generate private key
 openssl genrsa -out $keyFile 1024 

 # Generate CSR
 openssl req -new -key $keyFile -out $csrFile

 echo ""
 echo "Please enter the number of days which SSL Certificate will be valid:"
 read DAYS
 echo ""

 # Generate Self Signed Key
 openssl x509 -req -days $DAYS -in $csrFile -signkey $keyFile -out $crtFile
done
Or download the script below... Download: [download id="8"] bash script How to add gencert command to your system:
  1. Download the gencert bash script
  2. Extract the file
  3. chmod u+x gencert
  4. then copy the gencert file to /bin/
  5. Wallaah! You're done!