acdedc
#!/bin/sh
acdedc
umask 077
acdedc
acdedc
answers() {
acdedc
	echo --
acdedc
	echo SomeState
acdedc
	echo SomeCity
acdedc
	echo SomeOrganization
acdedc
	echo SomeOrganizationalUnit
acdedc
	echo localhost.localdomain
acdedc
	echo root@localhost.localdomain
acdedc
}
acdedc
acdedc
if [ $# -eq 0 ] ; then
acdedc
	echo $"Usage: `basename $0` filename [...]"
acdedc
	exit 0
acdedc
fi
acdedc
acdedc
for target in $@ ; do
acdedc
	PEM1=`/bin/mktemp /tmp/openssl.XXXXXX`
acdedc
	PEM2=`/bin/mktemp /tmp/openssl.XXXXXX`
acdedc
	trap "rm -f $PEM1 $PEM2" SIGINT
acdedc
	answers | /usr/bin/openssl req -newkey rsa:2048 -keyout $PEM1 -nodes -x509 -days 365 -out $PEM2 2> /dev/null
acdedc
	cat $PEM1 >  ${target}
acdedc
	echo ""   >> ${target}
acdedc
	cat $PEM2 >> ${target}
acdedc
	rm -f $PEM1 $PEM2
acdedc
done