1998-12-21 18:52:47 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2000-03-14 03:35:37 +08:00
|
|
|
digest='-md5'
|
1999-01-03 03:01:41 +08:00
|
|
|
reqcmd="../apps/openssl req"
|
|
|
|
x509cmd="../apps/openssl x509 $digest"
|
|
|
|
verifycmd="../apps/openssl verify"
|
1999-06-18 05:10:35 +08:00
|
|
|
dummycnf="../apps/openssl.cnf"
|
1998-12-21 18:52:47 +08:00
|
|
|
|
|
|
|
CAkey="keyCA.ss"
|
|
|
|
CAcert="certCA.ss"
|
|
|
|
CAreq="reqCA.ss"
|
|
|
|
CAconf="CAss.cnf"
|
|
|
|
CAreq2="req2CA.ss" # temp
|
|
|
|
|
|
|
|
Uconf="Uss.cnf"
|
|
|
|
Ukey="keyU.ss"
|
|
|
|
Ureq="reqU.ss"
|
|
|
|
Ucert="certU.ss"
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "make a certificate request using 'req'"
|
2000-03-14 03:24:39 +08:00
|
|
|
|
2000-03-14 04:31:46 +08:00
|
|
|
if ../apps/openssl no-rsa; then
|
2000-03-14 03:24:39 +08:00
|
|
|
req_new='-newkey dsa:../apps/dsa512.pem'
|
2000-03-14 04:31:46 +08:00
|
|
|
else
|
|
|
|
req_new='-new'
|
2000-03-14 03:24:39 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
$reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss
|
1998-12-21 18:52:47 +08:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "error using 'req' to generate a certificate request"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
echo "convert the certificate request into a self signed certificate using 'x509'"
|
|
|
|
$x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey >err.ss
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "error using 'x509' to self sign a certificate request"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "convert a certificate into a certificate request using 'x509'"
|
|
|
|
$x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "error using 'x509' convert a certificate to a certificate request"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1999-06-18 05:10:35 +08:00
|
|
|
$reqcmd -config $dummycnf -verify -in $CAreq -noout
|
1998-12-21 18:52:47 +08:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo first generated request is invalid
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1999-06-18 05:10:35 +08:00
|
|
|
$reqcmd -config $dummycnf -verify -in $CAreq2 -noout
|
1998-12-21 18:52:47 +08:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo second generated request is invalid
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$verifycmd -CAfile $CAcert $CAcert
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo first generated cert is invalid
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "make another certificate request using 'req'"
|
2000-03-14 03:24:39 +08:00
|
|
|
$reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss
|
1998-12-21 18:52:47 +08:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "error using 'req' to generate a certificate request"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "sign certificate request with the just created CA via 'x509'"
|
|
|
|
$x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey >err.ss
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "error using 'x509' to sign a certificate request"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$verifycmd -CAfile $CAcert $Ucert
|
|
|
|
echo
|
|
|
|
echo "Certificate details"
|
|
|
|
$x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo The generated CA certificate is $CAcert
|
|
|
|
echo The generated CA private key is $CAkey
|
|
|
|
|
|
|
|
echo The generated user certificate is $Ucert
|
|
|
|
echo The generated user private key is $Ukey
|
|
|
|
|
|
|
|
/bin/rm err.ss
|
|
|
|
exit 0
|