Blame SOURCES/renew-dummy-cert

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