Tag Archives: shell

simple shell script to generate ssl certs

hi there
This one is for commercial SSL certs

#!/bin/bash
if [ $1 ]; then
    if [ -d $1 ]; then
        echo "dir $1 exists exiting"
        exit
    else
        mkdir $1
    fi
    openssl genrsa -out $1/$1.key 2048
    openssl req -new -key $1/$1.key -out $1/$1.csr
else
    echo "usage generate.sh domain.tld"
fi

This one for self signed certs

#!/bin/bash
if [ $1 ]; then
    if [ -d $1 ]; then
        echo "dir $1 exists exiting"
        exit
    else
        mkdir $1
    fi
    openssl genrsa -out $1/$1.key 2048
    openssl req -new -key $1/$1.key -out $1/$1.csr
    openssl x509 -req -days 1024 -in $1/$1.csr -signkey $1/$1.key -out $1/$1.crt
else
    echo "usage generate.sh domain.tld"
fi

Here is a script to show the SSL Info out of an Cert

#!/bin/bash
if [ $1 ]; then
    if [ -d $1 ]; then
        openssl x509 -in $1/$1.crt -noout -text
        openssl req -text -in $1/$1.csr
    fi
else
    echo "usage showsslinfo.sh domain.tld"
fi

have fun!