@@ -46,14 +46,19 @@ http {
46
46
ssl_certificate localhost.crt;
47
47
48
48
ssl_verify_client on;
49
- ssl_client_certificate int- root.crt;
49
+ ssl_client_certificate root.crt;
50
50
51
- add_header X-Verify $ssl_client_verify;
51
+ add_header X-Verify $ssl_client_verify always ;
52
52
53
53
server {
54
54
listen 127.0.0.1:8080 ssl;
55
55
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;
57
62
}
58
63
}
59
64
@@ -80,9 +85,13 @@ default_md = sha256
80
85
policy = myca_policy
81
86
serial = $d /certserial
82
87
default_days = 1
88
+ x509_extensions = myca_extensions
83
89
84
90
[ myca_policy ]
85
91
commonName = supplied
92
+
93
+ [ myca_extensions ]
94
+ basicConstraints = critical,CA:TRUE
86
95
EOF
87
96
88
97
foreach my $name (' root' , ' localhost' ) {
@@ -93,7 +102,7 @@ foreach my $name ('root', 'localhost') {
93
102
or die " Can't create certificate for $name : $! \n " ;
94
103
}
95
104
96
- foreach my $name (' int' , ' end' ) {
105
+ foreach my $name (' int' , ' int2 ' , ' end' ) {
97
106
system (" openssl req -new "
98
107
. " -config $d /openssl.conf -subj /CN=$name / "
99
108
. " -out $d /$name .csr -keyout $d /$name .key "
@@ -112,20 +121,28 @@ system("openssl ca -batch -config $d/ca.conf "
112
121
113
122
system (" openssl ca -batch -config $d /ca.conf "
114
123
. " -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 "
115
130
. " -subj /CN=end/ -in $d /end.csr -out $d /end.crt "
116
131
. " >>$d /openssl.out 2>&1" ) == 0
117
132
or die " Can't sign certificate for end: $! \n " ;
118
133
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' ));
121
138
122
139
$t -> write_file(' t' , ' ' );
123
140
$t -> run();
124
141
125
142
# ##############################################################################
126
143
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' );
129
146
130
147
# ##############################################################################
131
148
0 commit comments