Import OpenSSL-0.9.8i.
[dragonfly.git] / crypto / openssl-0.9.7d / test / testss
blob8d3557f356d9a1697d874e105eb87c3d5c36e41b
1 #!/bin/sh
3 digest='-md5'
4 reqcmd="../apps/openssl req"
5 x509cmd="../apps/openssl x509 $digest"
6 verifycmd="../apps/openssl verify"
7 dummycnf="../apps/openssl.cnf"
9 CAkey="keyCA.ss"
10 CAcert="certCA.ss"
11 CAreq="reqCA.ss"
12 CAconf="CAss.cnf"
13 CAreq2="req2CA.ss" # temp
15 Uconf="Uss.cnf"
16 Ukey="keyU.ss"
17 Ureq="reqU.ss"
18 Ucert="certU.ss"
20 echo
21 echo "make a certificate request using 'req'"
23 echo "string to make the random number generator think it has entropy" >> ./.rnd
25 if ../apps/openssl no-rsa; then
26 req_new='-newkey dsa:../apps/dsa512.pem'
27 else
28 req_new='-new'
31 $reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss
32 if [ $? != 0 ]; then
33 echo "error using 'req' to generate a certificate request"
34 exit 1
36 echo
37 echo "convert the certificate request into a self signed certificate using 'x509'"
38 $x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey >err.ss
39 if [ $? != 0 ]; then
40 echo "error using 'x509' to self sign a certificate request"
41 exit 1
44 echo
45 echo "convert a certificate into a certificate request using 'x509'"
46 $x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss
47 if [ $? != 0 ]; then
48 echo "error using 'x509' convert a certificate to a certificate request"
49 exit 1
52 $reqcmd -config $dummycnf -verify -in $CAreq -noout
53 if [ $? != 0 ]; then
54 echo first generated request is invalid
55 exit 1
58 $reqcmd -config $dummycnf -verify -in $CAreq2 -noout
59 if [ $? != 0 ]; then
60 echo second generated request is invalid
61 exit 1
64 $verifycmd -CAfile $CAcert $CAcert
65 if [ $? != 0 ]; then
66 echo first generated cert is invalid
67 exit 1
70 echo
71 echo "make another certificate request using 'req'"
72 $reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss
73 if [ $? != 0 ]; then
74 echo "error using 'req' to generate a certificate request"
75 exit 1
78 echo
79 echo "sign certificate request with the just created CA via 'x509'"
80 $x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey >err.ss
81 if [ $? != 0 ]; then
82 echo "error using 'x509' to sign a certificate request"
83 exit 1
86 $verifycmd -CAfile $CAcert $Ucert
87 echo
88 echo "Certificate details"
89 $x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert
91 echo
92 echo The generated CA certificate is $CAcert
93 echo The generated CA private key is $CAkey
95 echo The generated user certificate is $Ucert
96 echo The generated user private key is $Ukey
98 /bin/rm err.ss
99 exit 0