view make-certificate @ 0:e85e3470a41e

Initial commit of useful scripts
author IBBoard <dev@ibboard.co.uk>
date Sat, 02 Aug 2014 19:31:02 +0100
parents
children 14c88dd76d53
line wrap: on
line source

#! /bin/bash

set -e

if [ $# -ne 1 ]; then
	echo "Usage: $0 <key-name>"
	exit 1
fi

if [ ! -d ~/Websites/certs/ ]; then
	echo "~/Websites/certs/ didn't exist - can't create certs"
	exit 1
fi

pushd ~/Websites/certs/

#openssl genrsa -des3 -out $1.key 4096
#openssl req -new -key $1.key -out $1.csr
#openssl x509 -req -days 365 -in $1.csr -CA ~/.ssh/CA/ca.crt -CAkey ~/.ssh/CA/ca.key -CAserial ~/.ssh/CA/ca.srl -out $1.crt
#-set_serial $serial
#openssl rsa -in $1.key -out $1.key.insecure
#mv $1.key $1.key.secure
#mv $1.key.insecure $1.key
#echo $(($serial + 1)) > ~/.ssh/CA/next-serial.dat
openssl req -nodes -newkey rsa:2048 -keyout $1.key -out $1.csr -subj "/C=GB/ST=Worcestershire/O=$1/CN=$1"
openssl x509 -req -days 365 -in $1.csr -CA ~/.ssh/CA/ca.crt -CAkey ~/.ssh/CA/ca.key -CAserial ~/.ssh/CA/ca.srl -out $1.crt
popd