1998-12-21 10:52:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-02-01 23:48:37 +00:00
|
|
|
digest='-sha1'
|
|
|
|
reqcmd="../util/shlib_wrap.sh ../apps/openssl req"
|
|
|
|
x509cmd="../util/shlib_wrap.sh ../apps/openssl x509 $digest"
|
|
|
|
verifycmd="../util/shlib_wrap.sh ../apps/openssl verify"
|
1999-06-17 21:10:35 +00:00
|
|
|
dummycnf="../apps/openssl.cnf"
|
1998-12-21 10:52:47 +00:00
|
|
|
|
|
|
|
CAkey="keyCA.ss"
|
|
|
|
CAcert="certCA.ss"
|
2015-05-06 16:48:48 +00:00
|
|
|
CAserial="certCA.srl"
|
1998-12-21 10:52:47 +00:00
|
|
|
CAreq="reqCA.ss"
|
|
|
|
CAconf="CAss.cnf"
|
|
|
|
CAreq2="req2CA.ss" # temp
|
|
|
|
|
|
|
|
Uconf="Uss.cnf"
|
|
|
|
Ukey="keyU.ss"
|
|
|
|
Ureq="reqU.ss"
|
|
|
|
Ucert="certU.ss"
|
|
|
|
|
2004-12-28 00:21:35 +00:00
|
|
|
P1conf="P1ss.cnf"
|
|
|
|
P1key="keyP1.ss"
|
|
|
|
P1req="reqP1.ss"
|
|
|
|
P1cert="certP1.ss"
|
|
|
|
P1intermediate="tmp_intP1.ss"
|
|
|
|
|
|
|
|
P2conf="P2ss.cnf"
|
|
|
|
P2key="keyP2.ss"
|
|
|
|
P2req="reqP2.ss"
|
|
|
|
P2cert="certP2.ss"
|
|
|
|
P2intermediate="tmp_intP2.ss"
|
|
|
|
|
2000-03-13 19:24:39 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo string to make the random number generator think it has entropy >> ./.rnd
|
2001-10-15 17:58:00 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
if ../util/shlib_wrap.sh ../apps/openssl no-rsa >/dev/null; then
|
2000-03-13 19:24:39 +00:00
|
|
|
req_new='-newkey dsa:../apps/dsa512.pem'
|
2000-03-13 20:31:46 +00:00
|
|
|
else
|
|
|
|
req_new='-new'
|
2000-03-13 19:24:39 +00:00
|
|
|
fi
|
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo make cert request
|
|
|
|
$reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo convert request into self-signed cert
|
|
|
|
$x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey -extfile $CAconf -extensions v3_ca >err.ss || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo convert cert into a cert request
|
|
|
|
$x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo verify request 1
|
|
|
|
$reqcmd -config $dummycnf -verify -in $CAreq -noout || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo verify request 1
|
|
|
|
$reqcmd -config $dummycnf -verify -in $CAreq2 -noout || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo verify signature
|
|
|
|
$verifycmd -CAfile $CAcert $CAcert || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo make a user cert request
|
|
|
|
$reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss || exit 1
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo sign user cert request
|
2015-05-06 16:48:48 +00:00
|
|
|
$x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial -extfile $Uconf -extensions v3_ee >err.ss || exit 1
|
2015-04-10 14:06:17 +00:00
|
|
|
$verifycmd -CAfile $CAcert $Ucert || exit 1
|
2004-12-28 00:21:35 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo Certificate details
|
|
|
|
$x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert || exit 1
|
|
|
|
|
|
|
|
echo make a proxy cert request
|
|
|
|
$reqcmd -config $P1conf -out $P1req -keyout $P1key $req_new >err.ss || exit 1
|
|
|
|
|
|
|
|
echo sign proxy with user cert
|
|
|
|
$x509cmd -CAcreateserial -in $P1req -days 30 -req -out $P1cert -CA $Ucert -CAkey $Ukey -extfile $P1conf -extensions v3_proxy >err.ss || exit 1
|
2004-12-28 00:21:35 +00:00
|
|
|
|
|
|
|
cat $Ucert > $P1intermediate
|
|
|
|
$verifycmd -CAfile $CAcert -untrusted $P1intermediate $P1cert
|
2015-04-10 14:06:17 +00:00
|
|
|
echo Certificate details
|
2004-12-28 00:21:35 +00:00
|
|
|
$x509cmd -subject -issuer -startdate -enddate -noout -in $P1cert
|
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo make another proxy cert request
|
|
|
|
$reqcmd -config $P2conf -out $P2req -keyout $P2key $req_new >err.ss || exit 1
|
2004-12-28 00:21:35 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo sign second proxy cert request with the first proxy cert
|
|
|
|
$x509cmd -CAcreateserial -in $P2req -days 30 -req -out $P2cert -CA $P1cert -CAkey $P1key -extfile $P2conf -extensions v3_proxy >err.ss || exit 1
|
2004-12-28 00:21:35 +00:00
|
|
|
|
2015-04-10 14:06:17 +00:00
|
|
|
echo Certificate details
|
2004-12-28 00:21:35 +00:00
|
|
|
cat $Ucert $P1cert > $P2intermediate
|
|
|
|
$verifycmd -CAfile $CAcert -untrusted $P2intermediate $P2cert
|
|
|
|
$x509cmd -subject -issuer -startdate -enddate -noout -in $P2cert
|
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
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
|
2004-12-28 00:21:35 +00:00
|
|
|
echo The first generated proxy certificate is $P1cert
|
|
|
|
echo The first generated proxy private key is $P1key
|
|
|
|
echo The second generated proxy certificate is $P2cert
|
|
|
|
echo The second generated proxy private key is $P2key
|
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
/bin/rm err.ss
|
|
|
|
exit 0
|