annotate ssl.t @ 1488:dbce8fb5f5f8

Tests: align with OpenSSL security level 2. This updates minimum requirements to 2048 bit RSA keys and SHA-2 message digest.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 09 Jul 2019 13:37:55 +0300
parents f9718a0773b9
children c6f27bcdd9d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
4 # (C) Andrey Zelenkov
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5 # (C) Nginx, Inc.
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 # Tests for http ssl module.
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use warnings;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use strict;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 use Test::More;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
1325
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
16 use Socket qw/ CRLF /;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
17
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 BEGIN { use FindBin; chdir($FindBin::Bin); }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 use lib 'lib';
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 use Test::Nginx;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 select STDERR; $| = 1;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 select STDOUT; $| = 1;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
430
a82b02635614 Tests: skip ssl tests with ancient IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
28 eval { require IO::Socket::SSL; };
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
430
a82b02635614 Tests: skip ssl tests with ancient IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
a82b02635614 Tests: skip ssl tests with ancient IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
1325
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
33 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/)
1449
eeababfd8726 Tests: moved $ssl_server_name tests in http to ssl_sni.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1447
diff changeset
34 ->has_daemon('openssl')->plan(23);
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
36 $t->write_file_expand('nginx.conf', <<'EOF');
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS%%
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 daemon off;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 events {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 http {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 %%TEST_GLOBALS_HTTP%%
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
48 ssl_certificate_key localhost.key;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
49 ssl_certificate localhost.crt;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
50 ssl_session_tickets off;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
51
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
53 listen 127.0.0.1:8085 ssl;
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
54 listen 127.0.0.1:8080;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 server_name localhost;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
57 ssl_certificate_key inner.key;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
58 ssl_certificate inner.crt;
503
071e8941e3bf Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents: 430
diff changeset
59 ssl_session_cache shared:SSL:1m;
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
60 ssl_verify_client optional_no_ca;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 location /reuse {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 return 200 "body $ssl_session_reused";
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 location /id {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 return 200 "body $ssl_session_id";
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 }
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
68 location /cipher {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
69 return 200 "body $ssl_cipher";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
70 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
71 location /client_verify {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
72 return 200 "body $ssl_client_verify";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
73 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
74 location /protocol {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
75 return 200 "body $ssl_protocol";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
76 }
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
77 location /issuer {
1382
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
78 return 200 "body $ssl_client_i_dn:$ssl_client_i_dn_legacy";
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
79 }
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
80 location /subject {
1382
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
81 return 200 "body $ssl_client_s_dn:$ssl_client_s_dn_legacy";
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
82 }
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
83 location /time {
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
84 return 200 "body $ssl_client_v_start!$ssl_client_v_end!$ssl_client_v_remain";
1094
dd8f126afa32 Tests: client certificate time variables tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1093
diff changeset
85 }
1325
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
86
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
87 location /body {
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
88 add_header X-Body $request_body always;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
89 proxy_pass http://127.0.0.1:8080/;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
90 }
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
91 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
92
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
93 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
94 listen 127.0.0.1:8081;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
95 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
96
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
97 # Special case for enabled "ssl" directive.
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
98
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
99 ssl on;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
100 ssl_session_cache builtin;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
101 ssl_session_timeout 1;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
102
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
103 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
104 return 200 "body $ssl_session_reused";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
105 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
106 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
107
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
108 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
109 listen 127.0.0.1:8082 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
110 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
111
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
112 ssl_session_cache builtin:1000;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
113
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
114 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
115 return 200 "body $ssl_session_reused";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
116 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
117 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
118
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
119 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
120 listen 127.0.0.1:8083 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
121 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
122
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
123 ssl_session_cache none;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
124
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
125 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
126 return 200 "body $ssl_session_reused";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
127 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
128 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
129
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
130 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
131 listen 127.0.0.1:8084 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
132 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
133
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
134 ssl_session_cache off;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
135
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
136 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
137 return 200 "body $ssl_session_reused";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
138 }
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
139
1384
965bddf88b8f Tests: disabled session cache for $ssl_ciphers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1382
diff changeset
140 location /ciphers {
965bddf88b8f Tests: disabled session cache for $ssl_ciphers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1382
diff changeset
141 return 200 "body $ssl_ciphers";
965bddf88b8f Tests: disabled session cache for $ssl_ciphers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1382
diff changeset
142 }
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
143
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
144 location /protocol {
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
145 return 200 "body $ssl_protocol";
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
146 }
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 EOF
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 $t->write_file('openssl.conf', <<EOF);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1478
diff changeset
154 default_bits = 2048
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 encrypt_key = no
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 distinguished_name = req_distinguished_name
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 [ req_distinguished_name ]
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 EOF
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 my $d = $t->testdir();
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
162 $t->write_file('ca.conf', <<EOF);
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
163 [ ca ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
164 default_ca = myca
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
165
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
166 [ myca ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
167 new_certs_dir = $d
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
168 database = $d/certindex
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1478
diff changeset
169 default_md = sha256
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
170 policy = myca_policy
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
171 serial = $d/certserial
1094
dd8f126afa32 Tests: client certificate time variables tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1093
diff changeset
172 default_days = 3
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
173
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
174 [ myca_policy ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
175 commonName = supplied
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
176 EOF
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
177
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
178 $t->write_file('certserial', '1000');
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
179 $t->write_file('certindex', '');
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
180
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
181 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
182 . "-config $d/openssl.conf -subj /CN=issuer/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
183 . "-out $d/issuer.crt -keyout $d/issuer.key "
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
184 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
185 or die "Can't create certificate for issuer: $!\n";
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
186
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
187 system("openssl req -new "
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
188 . "-config $d/openssl.conf -subj /CN=subject/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
189 . "-out $d/subject.csr -keyout $d/subject.key "
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
190 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
191 or die "Can't create certificate for subject: $!\n";
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
192
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
193 system("openssl ca -batch -config $d/ca.conf "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
194 . "-keyfile $d/issuer.key -cert $d/issuer.crt "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
195 . "-subj /CN=subject/ -in $d/subject.csr -out $d/subject.crt "
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
196 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
197 or die "Can't sign certificate for subject: $!\n";
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
198
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
199 foreach my $name ('localhost', 'inner') {
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
200 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
201 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
202 . "-out $d/$name.crt -keyout $d/$name.key "
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
203 . ">>$d/openssl.out 2>&1") == 0
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
204 or die "Can't create certificate for $name: $!\n";
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
205 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
206
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
207 my $ctx = new IO::Socket::SSL::SSL_Context(
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
208 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
209 SSL_session_cache_size => 100);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
210
1324
918bf90466e0 Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1276
diff changeset
211 open OLDERR, ">&", \*STDERR; close STDERR;
1139
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
212 $t->run();
1324
918bf90466e0 Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1276
diff changeset
213 open STDERR, ">&", \*OLDERR;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
217 like(get('/reuse', 8085), qr/^body \.$/m, 'shared initial session');
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
218 like(get('/', 8081), qr/^body \.$/m, 'builtin initial session');
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
219 like(get('/', 8082), qr/^body \.$/m, 'builtin size initial session');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
220
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
221 SKIP: {
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
222 skip 'no TLS 1.3 sessions', 3 if get('/protocol', 8084) =~ /TLSv1.3/
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
223 && ($Net::SSLeay::VERSION < 1.88 || $IO::Socket::SSL::VERSION < 2.061);
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
224
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
225 like(get('/reuse', 8085), qr/^body r$/m, 'shared session reused');
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
226 like(get('/', 8081), qr/^body r$/m, 'builtin session reused');
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
227 like(get('/', 8082), qr/^body r$/m, 'builtin size session reused');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
228
1478
f9718a0773b9 Tests: skip TLS 1.3 session reuse tests with older Perl modules.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1449
diff changeset
229 }
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
230
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
231 like(get('/', 8083), qr/^body \.$/m, 'reused none initial session');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
232 like(get('/', 8083), qr/^body \.$/m, 'session not reused 1');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
233
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
234 like(get('/', 8084), qr/^body \.$/m, 'reused off initial session');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
235 like(get('/', 8084), qr/^body \.$/m, 'session not reused 2');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
236
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
237 # ssl certificate inheritance
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
238
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
239 my $s = get_ssl_socket($ctx, port(8081));
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
240 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN');
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
241
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
242 $s->close();
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
243
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
244 $s = get_ssl_socket($ctx, port(8085));
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
245 like($s->dump_peer_certificate(), qr/CN=inner/, 'CN inner');
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
246
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
247 $s->close();
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
248
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
249 # session timeout
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
250
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
251 select undef, undef, undef, 2.1;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
252
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
253 like(get('/', 8081), qr/^body \.$/m, 'session timeout');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
254
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
255 # embedded variables
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
256
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
257 like(get('/id', 8085), qr/^body \w{64}$/m, 'session id');
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
258 unlike(http_get('/id'), qr/body \w/, 'session id no ssl');
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
259 like(get('/cipher', 8085), qr/^body [\w-]+$/m, 'cipher');
1399
de181159f279 Tests: unbreak $ssl_ciphers test with BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1384
diff changeset
260 my $re = $t->has_module('BoringSSL') ? '' : qr/[:\w-]+/;
de181159f279 Tests: unbreak $ssl_ciphers test with BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1384
diff changeset
261 like(get('/ciphers', 8084), qr/^body $re$/m, 'ciphers');
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
262 like(get('/client_verify', 8085), qr/^body NONE$/m, 'client verify');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
263 like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol');
1382
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
264 like(cert('/issuer', 8085), qr!^body CN=issuer:/CN=issuer$!m, 'issuer');
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
265 like(cert('/subject', 8085), qr!^body CN=subject:/CN=subject$!m, 'subject');
cb1346b553aa Tests: simple https tests merged back.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1325
diff changeset
266 like(cert('/time', 8085), qr/^body [:\s\w]+![:\s\w]+![23]$/m, 'time');
1139
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
267
1325
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
268 # c->read->ready handling bug in ngx_ssl_recv(), triggered with chunked body
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
269
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
270 like(get_body('/body', '0123456789', 20, 5), qr/X-Body: (0123456789){100}/,
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
271 'request body chunked');
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
272
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
273 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
274
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
275 sub get {
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
276 my ($uri, $port) = @_;
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
277 my $s = get_ssl_socket($ctx, port($port)) or return;
1132
3d312b6a1a19 Tests: avoid $ssl_session_reused tests failure with OpenSSL 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
278 my $r = http_get($uri, socket => $s);
3d312b6a1a19 Tests: avoid $ssl_session_reused tests failure with OpenSSL 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
279 $s->close();
3d312b6a1a19 Tests: avoid $ssl_session_reused tests failure with OpenSSL 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
280 return $r;
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
281 }
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
282
1325
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
283 sub get_body {
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
284 my ($uri, $body, $len, $n) = @_;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
285 my $s = get_ssl_socket($ctx, port(8085)) or return;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
286 http("GET /body HTTP/1.1" . CRLF
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
287 . "Host: localhost" . CRLF
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
288 . "Connection: close" . CRLF
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
289 . "Transfer-Encoding: chunked" . CRLF . CRLF,
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
290 socket => $s, start => 1);
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
291 http("c8" . CRLF . $body x $len . CRLF, socket => $s, start => 1)
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
292 for 1 .. $n;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
293 my $r = http("0" . CRLF . CRLF, socket => $s);
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
294 $s->close();
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
295 return $r;
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
296 }
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
297
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
298 sub cert {
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
299 my ($uri, $port) = @_;
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
300 my $s = get_ssl_socket(undef, port($port),
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
301 SSL_cert_file => "$d/subject.crt",
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
302 SSL_key_file => "$d/subject.key") or return;
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
303 http_get($uri, socket => $s);
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
304 }
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
305
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 sub get_ssl_socket {
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
307 my ($ctx, $port, %extra) = @_;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
308 my $s;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310 eval {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311 local $SIG{ALRM} = sub { die "timeout\n" };
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312 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
313 alarm(8);
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
314 $s = IO::Socket::SSL->new(
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315 Proto => 'tcp',
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
316 PeerAddr => '127.0.0.1',
952
e9064d691790 Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 664
diff changeset
317 PeerPort => $port,
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
318 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
319 SSL_reuse_ctx => $ctx,
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
320 SSL_error_trap => sub { die $_[1] },
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
321 %extra
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
322 );
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
323 alarm(0);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
324 };
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
325 alarm(0);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
326
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
327 if ($@) {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
328 log_in("died: $@");
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
329 return undef;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
330 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
331
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332 return $s;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
333 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
334
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
335 ###############################################################################