]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/sslScripts/makeLocalCert
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / sslScripts / makeLocalCert
1 #! /bin/csh -f
2 #
3 # Make up-to-date localcert, clientcert, and dsacert keychains and roots.
4 #
5 set BUILD_DIR=$LOCAL_BUILD_DIR
6
7 echo === Creating certs and keychains for SSL testing ===
8
9 source sslKcSetup
10
11 set DSA_CT_INPUT=dsaCertToolInput
12 set AUTO_RUN=0
13 set DEFAULT_ACL=
14
15 while ( $#argv > 0 )
16 switch ( "$argv[1]" )
17 case a:
18 set AUTO_RUN = 1
19 shift
20 breaksw
21 case d:
22 set DEFAULT_ACL=a
23 shift
24 breaksw
25 default:
26 echo Usage: makeLocalCert \[a\(utorun\)\] \[d\(efault ACL\)\]
27 exit(1)
28 endsw
29 end
30
31 set ALL_KEYCHAINS="$LOCAL_KC $CLIENT_KC $DSA_KC $P12_KC"
32 set ALL_CERTS="$LOCAL_CERT $CLIENT_CERT $DSA_CERT"
33 #
34 if($AUTO_RUN == 1) then
35 echo deleting $ALL_KEYCHAINS from $KC_DIR
36 else
37 echo Preparing to delete $ALL_KEYCHAINS from $KC_DIR
38 echo Ctl-c to abort, or....
39 simplePrompt
40 endif
41 (cd $KC_DIR; rm -f $ALL_KEYCHAINS)
42 rm -f $ALL_CERTS
43
44 echo Creating $LOCAL_KC and $LOCAL_CERT...
45 set cmd="certtool c k=$LOCAL_KC c Z o=$LOCAL_CERT d p=$LOCAL_KC_PWD $DEFAULT_ACL x=S"
46 echo $cmd
47 $cmd || exit(1)
48
49 echo Creating $CLIENT_KC and $CLIENT_CERT...
50 set cmd="certtool c k=$CLIENT_KC c Z o=$CLIENT_CERT d p=$CLIENT_KC_PWD $DEFAULT_ACL x=s"
51 echo $cmd
52 $cmd || exit(1)
53
54 echo Creating $DSA_KC and $DSA_CERT...
55 set cmd="certtool c k=$DSA_KC c o=$DSA_CERT p=$DSA_KC_PWD $DEFAULT_ACL d"
56 echo $cmd \< $DSA_CT_INPUT \> /dev/null
57 $cmd < $DSA_CT_INPUT > /dev/null || exit(1)
58
59 echo Creating $P12_KC and root $P12_ROOT_CERT via import of $P12_PFX...
60 set cmd="certtool y k=$P12_KC c p=$P12_KC_PWD"
61 echo $cmd
62 $cmd > /dev/null || exit(1)
63 set cmd="security import $P12_PFX -k $P12_KC -P $P12_PFX_PWD"
64 echo $cmd
65 $cmd || exit(1)
66 set cmd="$BUILD_DIR/certsFromDb $P12_KC_PATH f $P12_CERT_BASE"
67 echo $cmd
68 $cmd || exit(1)
69 echo P12 import complete.
70
71 echo === Finished creating certs and keychains for SSL testing ===
72