how to make a self signed certificate

After a few years i always forgot how to recreate my self signed certificates with openssl for my webserver, smtp mailserver imapserver ftpserver etc. So i wrote a little script and as long as i dont forget about the script i dont have to remember anymore.

Here is an example shell script for self-signed certificates with openssl:

#!/bin/sh
N=$1
echo $1
openssl genrsa -out ${N}_pass.key 2048
openssl rsa -in ${N}_pass.key -out ${N}_server.key
openssl req -new -key ${N}_server.key -x509 -out ${N}_server.crt -days 999
cat ${N}_server.key ${N}_server.crt > ${N}_server.pem