#!/bin/sh

cd /etc/ssl/certs

echo -n "pemfile [foobar.pem]: "
read PEMFILE
[ -z "$PEMFILE" ] && exit

openssl req -new -x509 -nodes -days 1825 -out $PEMFILE -keyout $PEMFILE
chmod 600 $PEMFILE
[ -e temp_file ] && rm -f temp_file
dd if=/dev/urandom of=temp_file count=2
openssl dhparam -rand temp_file 512 >> $PEMFILE
ln -sf $PEMFILE `openssl x509 -noout -hash < $PEMFILE`.0
