Blame SOURCES/renew-dummy-cert

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