Blame SOURCES/renew-dummy-cert

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