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