annotate ssl_certificate_chain.t @ 1858:cdcd75657e52

Tests: added has_feature() tests for IO::Socket::SSL. The following distinct features supported: - "socket_ssl", which requires IO::Socket::SSL and also implies existance of the IO::Socket::SSL::SSL_VERIFY_NONE() symbol. It is used by most of the tests. - "socket_ssl_sni", which requires IO::Socket::SSL with the can_client_sni() function (1.84), and SNI support available in Net::SSLeay and the OpenSSL library being used. Used by ssl_sni.t, ssl_sni_sessions.t, stream_ssl_preread.t. Additional Net::SSLeay testing is believed to be unneeded and was removed. - "socket_ssl_alpn", which requires IO::Socket::SSL with ALPN support (2.009), and ALPN support in Net::SSLeay and the OpenSSL library being used. Used by h2_ssl.t, h2_ssl_verify_client.t, stream_ssl_alpn.t, stream_ssl_preread_alpn.t. - "socket_ssl_sslversion", which requires IO::Socket::SSL with the get_sslversion() and get_sslversion_int() methods (1.964). Used by mail_imap_ssl.t. - "socket_ssl_reused", which requires IO::Socket::SSL with the get_session_reused() method (2.057). To be used in the following patches. This makes it possible to simplify and unify various SSL tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 May 2023 18:07:02 +0300
parents 173c9b792c2c
children a797d7428fa5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http ssl module with certificate chain.
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
1858
cdcd75657e52 Tests: added has_feature() tests for IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1815
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 ->has_daemon('openssl')->plan(3);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 $t->write_file_expand('nginx.conf', <<'EOF');
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
41 listen 127.0.0.1:8080 ssl;
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server_name localhost;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 ssl_certificate_key end.key;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 ssl_certificate end.crt;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
49 listen 127.0.0.1:8081 ssl;
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 server_name localhost;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 ssl_certificate_key int.key;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 ssl_certificate int.crt;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
57 listen 127.0.0.1:8082 ssl;
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 server_name localhost;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 ssl_certificate_key end.key;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 ssl_certificate end-int.crt;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 EOF
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 my $d = $t->testdir();
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 $t->write_file('openssl.conf', <<EOF);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
71 default_bits = 2048
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 encrypt_key = no
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 distinguished_name = req_distinguished_name
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 [ req_distinguished_name ]
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 EOF
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 $t->write_file('ca.conf', <<EOF);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 [ ca ]
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 default_ca = myca
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 [ myca ]
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 new_certs_dir = $d
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 database = $d/certindex
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
84 default_md = sha256
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 policy = myca_policy
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 serial = $d/certserial
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 default_days = 1
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 x509_extensions = myca_extensions
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 [ myca_policy ]
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 commonName = supplied
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 [ myca_extensions ]
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 basicConstraints = critical,CA:TRUE
1815
173c9b792c2c Tests: fixed hostname verification in ssl_certificate_chain.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
95 subjectAltName = IP:127.0.0.1
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 EOF
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 foreach my $name ('root') {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
100 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
101 . "-out $d/$name.crt -keyout $d/$name.key "
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 . ">>$d/openssl.out 2>&1") == 0
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 or die "Can't create certificate for $name: $!\n";
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106 foreach my $name ('int', 'end') {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 system("openssl req -new "
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
108 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
109 . "-out $d/$name.csr -keyout $d/$name.key "
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 . ">>$d/openssl.out 2>&1") == 0
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 or die "Can't create certificate for $name: $!\n";
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 $t->write_file('certserial', '1000');
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 $t->write_file('certindex', '');
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
117 system("openssl ca -batch -config $d/ca.conf "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
118 . "-keyfile $d/root.key -cert $d/root.crt "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
119 . "-subj /CN=int/ -in $d/int.csr -out $d/int.crt "
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 . ">>$d/openssl.out 2>&1") == 0
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 or die "Can't sign certificate for int: $!\n";
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
123 system("openssl ca -batch -config $d/ca.conf "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
124 . "-keyfile $d/int.key -cert $d/int.crt "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
125 . "-subj /CN=end/ -in $d/end.csr -out $d/end.crt "
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 . ">>$d/openssl.out 2>&1") == 0
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 or die "Can't sign certificate for end: $!\n";
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 $t->write_file('end-int.crt',
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 $t->read_file('end.crt') . $t->read_file('int.crt'));
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 $t->run();
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 ###############################################################################
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
136 is(get_ssl_socket(port(8080)), undef, 'incomplete chain');
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
137 ok(get_ssl_socket(port(8081)), 'intermediate');
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
138 ok(get_ssl_socket(port(8082)), 'intermediate server');
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 ###############################################################################
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 sub get_ssl_socket {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 my ($port) = @_;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 my ($s, $verify);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 eval {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 local $SIG{ALRM} = sub { die "timeout\n" };
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 local $SIG{PIPE} = sub { die "sigpipe\n" };
1421
4e48bf51714f Tests: aligned various generic read timeouts to http_end().
Sergey Kandaurov <pluknet@nginx.com>
parents: 1407
diff changeset
149 alarm(8);
686
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 $s = IO::Socket::SSL->new(
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 Proto => 'tcp',
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 PeerAddr => '127.0.0.1',
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 PeerPort => $port,
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER(),
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 SSL_ca_file => "$d/root.crt",
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 SSL_verify_callback => sub {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 my ($ok) = @_;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 $verify = $ok;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 return $ok;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 },
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 SSL_error_trap => sub { die $_[1] }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 );
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 alarm(0);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 };
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165 alarm(0);
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 if ($@) {
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168 log_in("died: $@");
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 return undef;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 return $verify;
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 }
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174
0af386a519d2 Tests: tests for http ssl module with certificate chain.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 ###############################################################################