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