5 # creates self-signed openssl certificates based on
6 # the local hostname or the given one
7 # Fallback to localhost if not set.
9 # Juergen Daubert, jue at crux dot nu
13 echo "usage: ${0##*/} <key> <cert> [hostname]"
14 echo " key full path to openssl private key"
15 echo " cert full path to openssl certificate"
16 echo " hostname host name of certificate"
20 if [ ! "$1" -o ! "$2" ]; then
27 FQDN
=$
(hostname
-f) || FQDN
=localhost
28 if [ ! -z "$3" ]; then
31 INFO
=".\n.\n.\n.\n.\n$FQDN\nroot@$FQDN"
32 OPTS
="req -new -nodes -x509 -days 365 -newkey rsa:2048"
34 printf "$INFO\n" | openssl
$OPTS -out $CRT -keyout $KEY 2> /dev
/null
37 echo "Error: creating of certificate failed"
40 echo "SSL certificate $CRT with key $KEY for host $FQDN created"