Blame SOURCES/renew-dummy-cert

e4b8d1
#!/bin/bash
e4b8d1
e4b8d1
if [ $# -eq 0 ]; then
e4b8d1
	echo $"Usage: `basename $0` filename" 1>&2
e4b8d1
	exit 1
e4b8d1
fi
e4b8d1
e4b8d1
PEM=$1
e4b8d1
REQ=`/bin/mktemp /tmp/openssl.XXXXXX`
e4b8d1
KEY=`/bin/mktemp /tmp/openssl.XXXXXX`
e4b8d1
CRT=`/bin/mktemp /tmp/openssl.XXXXXX`
e4b8d1
NEW=${PEM}_
e4b8d1
e4b8d1
trap "rm -f $REQ $KEY $CRT $NEW" SIGINT
e4b8d1
e4b8d1
if [ ! -f $PEM ]; then
e4b8d1
	echo "$PEM: file not found" 1>&2
e4b8d1
	exit 1
e4b8d1
fi
e4b8d1
e4b8d1
umask 077
e4b8d1
e4b8d1
OWNER=`ls -l $PEM | awk '{ printf "%s.%s", $3, $4; }'`
e4b8d1
e4b8d1
openssl rsa -inform pem -in $PEM -out $KEY
e4b8d1
openssl x509 -x509toreq -in $PEM -signkey $KEY -out $REQ
e4b8d1
openssl x509 -req -in $REQ -signkey $KEY -days 365 \
e4b8d1
	-extfile /etc/pki/tls/openssl.cnf -extensions v3_ca -out $CRT
e4b8d1
e4b8d1
(cat $KEY ; echo "" ; cat $CRT) > $NEW
e4b8d1
e4b8d1
chown $OWNER $NEW
e4b8d1
e4b8d1
mv -f $NEW $PEM
e4b8d1
e4b8d1
rm -f $REQ $KEY $CRT
e4b8d1
e4b8d1
exit 0
e4b8d1