4 reqcmd
="../util/shlib_wrap.sh ../apps/openssl req"
5 x509cmd
="../util/shlib_wrap.sh ../apps/openssl x509 $digest"
6 verifycmd
="../util/shlib_wrap.sh ../apps/openssl verify"
7 dummycnf
="../apps/openssl.cnf"
13 CAreq2
="req2CA.ss" # temp
24 P1intermediate
="tmp_intP1.ss"
30 P2intermediate
="tmp_intP2.ss"
33 echo "make a certificate request using 'req'"
35 echo "string to make the random number generator think it has entropy" >> .
/.rnd
37 if ..
/util
/shlib_wrap.sh ..
/apps
/openssl no-rsa
; then
38 req_new
='-newkey dsa:../apps/dsa512.pem'
43 $reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss
45 echo "error using 'req' to generate a certificate request"
49 echo "convert the certificate request into a self signed certificate using 'x509'"
50 $x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey -extfile $CAconf -extensions v3_ca
>err.ss
52 echo "error using 'x509' to self sign a certificate request"
57 echo "convert a certificate into a certificate request using 'x509'"
58 $x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss
60 echo "error using 'x509' convert a certificate to a certificate request"
64 $reqcmd -config $dummycnf -verify -in $CAreq -noout
66 echo first generated request is invalid
70 $reqcmd -config $dummycnf -verify -in $CAreq2 -noout
72 echo second generated request is invalid
76 $verifycmd -CAfile $CAcert $CAcert
78 echo first generated cert is invalid
83 echo "make a user certificate request using 'req'"
84 $reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss
86 echo "error using 'req' to generate a user certificate request"
91 echo "sign user certificate request with the just created CA via 'x509'"
92 $x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -extfile $Uconf -extensions v3_ee
>err.ss
94 echo "error using 'x509' to sign a user certificate request"
98 $verifycmd -CAfile $CAcert $Ucert
100 echo "Certificate details"
101 $x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert
104 echo "make a proxy certificate request using 'req'"
105 $reqcmd -config $P1conf -out $P1req -keyout $P1key $req_new >err.ss
107 echo "error using 'req' to generate a proxy certificate request"
112 echo "sign proxy certificate request with the just created user certificate via 'x509'"
113 $x509cmd -CAcreateserial -in $P1req -days 30 -req -out $P1cert -CA $Ucert -CAkey $Ukey -extfile $P1conf -extensions v3_proxy
>err.ss
115 echo "error using 'x509' to sign a proxy certificate request"
119 cat $Ucert > $P1intermediate
120 $verifycmd -CAfile $CAcert -untrusted $P1intermediate $P1cert
122 echo "Certificate details"
123 $x509cmd -subject -issuer -startdate -enddate -noout -in $P1cert
126 echo "make another proxy certificate request using 'req'"
127 $reqcmd -config $P2conf -out $P2req -keyout $P2key $req_new >err.ss
129 echo "error using 'req' to generate another proxy certificate request"
134 echo "sign second proxy certificate request with the first proxy certificate via 'x509'"
135 $x509cmd -CAcreateserial -in $P2req -days 30 -req -out $P2cert -CA $P1cert -CAkey $P1key -extfile $P2conf -extensions v3_proxy
>err.ss
137 echo "error using 'x509' to sign a second proxy certificate request"
141 cat $Ucert $P1cert > $P2intermediate
142 $verifycmd -CAfile $CAcert -untrusted $P2intermediate $P2cert
144 echo "Certificate details"
145 $x509cmd -subject -issuer -startdate -enddate -noout -in $P2cert
148 echo The generated CA certificate is
$CAcert
149 echo The generated CA private key is
$CAkey
151 echo The generated user certificate is
$Ucert
152 echo The generated user private key is
$Ukey
154 echo The first generated proxy certificate is
$P1cert
155 echo The first generated proxy private key is
$P1key
157 echo The second generated proxy certificate is
$P2cert
158 echo The second generated proxy private key is
$P2key
161 #/bin/rm $P1intermediate
162 #/bin/rm $P2intermediate