Blame SOURCES/renew-dummy-cert

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