Skip to content

Commit e739ecb

Browse files
committed
Tests: actually test the verification depth in ssl_verify_depth.t.
This reverts 5b22e2014f76. Two basic cases are now provided for a full chain: when the verification depth is big enough and when it is insufficient.
1 parent df55728 commit e739ecb

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

ssl_verify_depth.t

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,19 @@ http {
4646
ssl_certificate localhost.crt;
4747
4848
ssl_verify_client on;
49-
ssl_client_certificate int-root.crt;
49+
ssl_client_certificate root.crt;
5050
51-
add_header X-Verify $ssl_client_verify;
51+
add_header X-Verify $ssl_client_verify always;
5252
5353
server {
5454
listen 127.0.0.1:8080 ssl;
5555
server_name localhost;
56-
ssl_verify_depth 0;
56+
ssl_verify_depth 3;
57+
}
58+
59+
server {
60+
listen 127.0.0.1:8081 ssl;
61+
server_name localhost;
5762
}
5863
}
5964
@@ -80,9 +85,13 @@ default_md = sha256
8085
policy = myca_policy
8186
serial = $d/certserial
8287
default_days = 1
88+
x509_extensions = myca_extensions
8389
8490
[ myca_policy ]
8591
commonName = supplied
92+
93+
[ myca_extensions ]
94+
basicConstraints = critical,CA:TRUE
8695
EOF
8796

8897
foreach my $name ('root', 'localhost') {
@@ -93,7 +102,7 @@ foreach my $name ('root', 'localhost') {
93102
or die "Can't create certificate for $name: $!\n";
94103
}
95104

96-
foreach my $name ('int', 'end') {
105+
foreach my $name ('int', 'int2', 'end') {
97106
system("openssl req -new "
98107
. "-config $d/openssl.conf -subj /CN=$name/ "
99108
. "-out $d/$name.csr -keyout $d/$name.key "
@@ -112,20 +121,28 @@ system("openssl ca -batch -config $d/ca.conf "
112121

113122
system("openssl ca -batch -config $d/ca.conf "
114123
. "-keyfile $d/int.key -cert $d/int.crt "
124+
. "-subj /CN=int2/ -in $d/int2.csr -out $d/int2.crt "
125+
. ">>$d/openssl.out 2>&1") == 0
126+
or die "Can't sign certificate for int2: $!\n";
127+
128+
system("openssl ca -batch -config $d/ca.conf "
129+
. "-keyfile $d/int2.key -cert $d/int2.crt "
115130
. "-subj /CN=end/ -in $d/end.csr -out $d/end.crt "
116131
. ">>$d/openssl.out 2>&1") == 0
117132
or die "Can't sign certificate for end: $!\n";
118133

119-
$t->write_file('int-root.crt',
120-
$t->read_file('int.crt') . $t->read_file('root.crt'));
134+
$t->write_file('client.key', $t->read_file('end.key') .
135+
$t->read_file('int.key') . $t->read_file('int2.key'));
136+
$t->write_file('client.crt', $t->read_file('end.crt') .
137+
$t->read_file('int.crt') . $t->read_file('int2.crt'));
121138

122139
$t->write_file('t', '');
123140
$t->run();
124141

125142
###############################################################################
126143

127-
like(get(8080, 'root'), qr/SUCCESS/, 'verify depth');
128-
like(get(8080, 'end'), qr/400 Bad Request/, 'verify depth limited');
144+
like(get(8080, 'client'), qr/SUCCESS/, 'verify depth');
145+
like(get(8081, 'client'), qr/FAILED/, 'verify depth limited');
129146

130147
###############################################################################
131148

0 commit comments

Comments
 (0)