Generating SSL certificates using OpenSSL

Administration, Info.Tech, Operating Systems Add comments

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: gencert (764) 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!



Comments are closed.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in