]> git.saurik.com Git - apple/security.git/blame - SecurityTests/clxutils/signerAndSubjSsl/doTest
Security-57740.31.2.tar.gz
[apple/security.git] / SecurityTests / clxutils / signerAndSubjSsl / doTest
CommitLineData
d8f41ccd
A
1#! /bin/csh -f
2#
3# Test SSL's hostname compare using subjectAltName extensions.
4#
5# these can be overridden by the 'q' and 'v' cmd line options
6#
7set QUIET = 0
8set VERBOSE = 0
9#
10while ( $#argv > 0 )
11 switch ( "$argv[1]" )
12 case v:
13 set VERBOSE = 1
14 shift
15 breaksw
16 case q:
17 set QUIET = 1
18 shift
19 breaksw
20 default:
21 echo usage: doTest \[q\] \[v\]
22 exit(1)
23 endsw
24end
25
26#
27# hard coded in signerAndSubjSsl
28#
29set ROOT_CERT = ssRootCert.der
30set LEAF_CERT = ssSubjCert.der
31set COMMON_NAME = something.org
32#
33# the common arguments to certcrl
34#
35set STD_CRL_ARGS = "-c $LEAF_CERT -C $ROOT_CERT -a -n -N -q"
36#
37# DNS_NAME goes in the leaf cert's subjectAltName, which is supposed to have precedence
38# over the common name (which is fixed at something.org).
39#
40set DNS_NAME = foo.bar
41set BAD_DNS_NAME = foo.foo.bar
42#
43if($QUIET == 0) then
44 echo === leaf cert with DNS name $DNS_NAME
45endif
46#
47set cmd = "signerAndSubjSsl d=$DNS_NAME q"
48if($VERBOSE == 1) then
49 echo $cmd
50endif
51$cmd || exit(1)
52#
53# Note the app is passing in $HOST_NAME which differs from the leaf cert's common name
54#
55if($QUIET == 0) then
56 echo === ...verify success with hostname $DNS_NAME
57endif
58set cmd = "certcrl $STD_CRL_ARGS -h $DNS_NAME"
59if($VERBOSE == 1) then
60 echo $cmd
61endif
62$cmd || exit(1)
63#
64if($QUIET == 0) then
65 echo === ...verify failure with common name $COMMON_NAME when DNS name present
66endif
67set cmd = "certcrl $STD_CRL_ARGS -h $COMMON_NAME -e=CSSMERR_TP_VERIFY_ACTION_FAILED"
68if($VERBOSE == 1) then
69 echo $cmd
70endif
71$cmd || exit(1)
72#
73if($QUIET == 0) then
74 echo === ...verify failure with host name $BAD_DNS_NAME
75endif
76set cmd = "certcrl $STD_CRL_ARGS -h $BAD_DNS_NAME -e=CSSMERR_TP_VERIFY_ACTION_FAILED"
77if($VERBOSE == 1) then
78 echo $cmd
79endif
80$cmd || exit(1)
81#
82######
83#
84set IP_ADDR = 1.0.5.8
85set IP_ADDR_PAD = 1.0.05.008
86set BAD_IP_ADDR = 2.0.5.8
87#
88if($QUIET == 0) then
89 echo === leaf cert with IP address $IP_ADDR
90endif
91set cmd = "signerAndSubjSsl i=$IP_ADDR q"
92if($VERBOSE == 1) then
93 echo $cmd
94endif
95$cmd || exit(1)
96#
97if($QUIET == 0) then
98 echo === ...verify with hostname $IP_ADDR
99endif
100set cmd = "certcrl $STD_CRL_ARGS -h $IP_ADDR"
101if($VERBOSE == 1) then
102 echo $cmd
103endif
104$cmd || exit(1)
105#
106if($QUIET == 0) then
107 echo === ...verify with hostname $IP_ADDR_PAD
108endif
109set cmd = "certcrl $STD_CRL_ARGS -h $IP_ADDR_PAD"
110if($VERBOSE == 1) then
111 echo $cmd
112endif
113$cmd || exit(1)
114#
115if($QUIET == 0) then
116 echo === ...verify with hostname $COMMON_NAME when no DNS name present
117endif
118set cmd = "certcrl $STD_CRL_ARGS -h $COMMON_NAME"
119if($VERBOSE == 1) then
120 echo $cmd
121endif
122$cmd || exit(1)
123#
124if($QUIET == 0) then
125 echo === ...verify failure with host name $BAD_IP_ADDR
126endif
127set cmd = "certcrl $STD_CRL_ARGS -h $BAD_IP_ADDR -e=CSSMERR_TP_VERIFY_ACTION_FAILED"
128if($VERBOSE == 1) then
129 echo $cmd
130endif
131$cmd || exit(1)
132#
133######
134#
135set DNS_WC_NAME = "*.foo.bar"
136set DNS_GOOD_WC_NAME = bar.foo.bar
137set DNS_BAD_WC_NAME = foo.bar
138#
139if($QUIET == 0) then
140 echo === leaf cert with DNS name "$DNS_WC_NAME"
141endif
142set cmd = "signerAndSubjSsl d=*.foo.bar q"
143if($VERBOSE == 1) then
144 echo "$cmd"
145endif
146signerAndSubjSsl "d=*.foo.bar" q || exit(1)
147#
148if($QUIET == 0) then
149 echo === ...verify with hostname $DNS_GOOD_WC_NAME
150endif
151set cmd = "certcrl $STD_CRL_ARGS -h $DNS_GOOD_WC_NAME"
152if($VERBOSE == 1) then
153 echo $cmd
154endif
155$cmd || exit(1)
156#
157if($QUIET == 0) then
158 echo === ...verify failure with hostname $DNS_BAD_WC_NAME
159endif
160set cmd = "certcrl $STD_CRL_ARGS -h $DNS_BAD_WC_NAME -e=CSSMERR_TP_VERIFY_ACTION_FAILED"
161if($VERBOSE == 1) then
162 echo $cmd
163endif
164$cmd || exit(1)
165#
166######
167#
168set DNS_WC_NAME = "*foo.bar"
169set DNS_GOOD_WC_NAME = barfoo.bar
170set DNS_BAD_WC_NAME = bar.foo.bar
171#
172if($QUIET == 0) then
173 echo === leaf cert with DNS name "$DNS_WC_NAME"
174endif
175set cmd = "signerAndSubjSsl d=*foo.bar q"
176if($VERBOSE == 1) then
177 echo "$cmd"
178endif
179signerAndSubjSsl "d=*foo.bar" q || exit(1)
180#
181if($QUIET == 0) then
182 echo === ...verify with hostname $DNS_GOOD_WC_NAME
183endif
184set cmd = "certcrl $STD_CRL_ARGS -h $DNS_GOOD_WC_NAME"
185if($VERBOSE == 1) then
186 echo $cmd
187endif
188$cmd || exit(1)
189#
190if($QUIET == 0) then
191 echo === ...verify failure with hostname $DNS_BAD_WC_NAME
192endif
193set cmd = "certcrl $STD_CRL_ARGS -h $DNS_BAD_WC_NAME -e=CSSMERR_TP_VERIFY_ACTION_FAILED"
194if($VERBOSE == 1) then
195 echo $cmd
196endif
197$cmd || exit(1)
198#
199######
200#
201if($QUIET == 0) then
202 echo === leaf cert with no DNS name, verify with common name
203endif
204set cmd = "signerAndSubjSsl q"
205if($VERBOSE == 1) then
206 echo $cmd
207endif
208$cmd || exit(1)
209set cmd = "certcrl $STD_CRL_ARGS -h $COMMON_NAME"
210if($VERBOSE == 1) then
211 echo $cmd
212endif
213$cmd || exit(1)
214echo ...signerAndSubjSslTest complete
215