Import of old SSLeay release: SSLeay 0.8.1b
[openssl.git] / test / testss
1 #!/bin/sh
2
3 digest='-mdc2'
4 reqcmd="../apps/ssleay req"
5 x509cmd="../apps/ssleay x509 $digest"
6 verifycmd="../apps/ssleay verify"
7
8 CAkey="keyCA.ss"
9 CAcert="certCA.ss"
10 CAreq="reqCA.ss"
11 CAconf="CAss.cnf"
12 CAreq2="req2CA.ss"      # temp
13
14 Uconf="Uss.cnf"
15 Ukey="keyU.ss"
16 Ureq="reqU.ss"
17 Ucert="certU.ss"
18
19 echo
20 echo "make a certificate request using 'req'"
21 $reqcmd -config $CAconf -out $CAreq -keyout $CAkey -new #>err.ss
22 if [ $? != 0 ]; then
23         echo "error using 'req' to generate a certificate request"
24         exit 1
25 fi
26 echo
27 echo "convert the certificate request into a self signed certificate using 'x509'"
28 $x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey >err.ss
29 if [ $? != 0 ]; then
30         echo "error using 'x509' to self sign a certificate request"
31         exit 1
32 fi
33
34 echo
35 echo "convert a certificate into a certificate request using 'x509'"
36 $x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss
37 if [ $? != 0 ]; then
38         echo "error using 'x509' convert a certificate to a certificate request"
39         exit 1
40 fi
41
42 $reqcmd -verify -in $CAreq -noout
43 if [ $? != 0 ]; then
44         echo first generated request is invalid
45         exit 1
46 fi
47
48 $reqcmd -verify -in $CAreq2 -noout
49 if [ $? != 0 ]; then
50         echo second generated request is invalid
51         exit 1
52 fi
53
54 $verifycmd -CAfile $CAcert $CAcert
55 if [ $? != 0 ]; then
56         echo first generated cert is invalid
57         exit 1
58 fi
59
60 echo
61 echo "make another certificate request using 'req'"
62 $reqcmd -config $Uconf -out $Ureq -keyout $Ukey -new >err.ss
63 if [ $? != 0 ]; then
64         echo "error using 'req' to generate a certificate request"
65         exit 1
66 fi
67
68 echo
69 echo "sign certificate request with the just created CA via 'x509'"
70 $x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey >err.ss
71 if [ $? != 0 ]; then
72         echo "error using 'x509' to sign a certificate request"
73         exit 1
74 fi
75
76 $verifycmd -CAfile $CAcert $Ucert
77 echo
78 echo "Certificate details"
79 $x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert
80
81 echo
82 echo The generated CA certificate is $CAcert
83 echo The generated CA private key is $CAkey
84
85 echo The generated user certificate is $Ucert
86 echo The generated user private key is $Ukey
87
88 /bin/rm err.ss
89 exit 0