:
# NAME:
#	mkcert - generate a signed certificate
#
# SYNOPSIS:
#	mkcert [-n][-k "rsa:bits"][-d "days"]
#
# DESCRIPTION:
#	This script runs req, to produce a certificate request file,
#	and a private key, then calls ca to sign it, and finally
#	outputs the issued certificat and private key to stdout.
#
# SEE ALSO:
#	SSLeay FAQ.
#
# AUTHOR:
#	Simon J. Gerraty <sjg@quick.com.au>
#

# RCSid:
#	$Id: mkcert,v 1.6 1998/10/29 01:04:19 sjg Exp $
#
#	@(#) Copyright (c) 1996 Simon J. Gerraty
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@quick.com.au
#

opt_str=k:d:n
. setopts.sh

umask 077
TF=/tmp/cr$$
/usr/local/ssl/bin/req -new -keyout $TF.key -out $TF.req ${opt_k:+-newkey} $opt_k ${opt_n:+-nodes} &&
/usr/local/ssl/bin/ca -verbose -in $TF.req -out $TF.cert ${opt_d:+-days} $opt_d &&
cat $TF.cert $TF.key | sed -n '/BEGIN/,$p' 
rm -f $TF.*

