annotate ssl.t @ 1325:f80176242a7e

Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 17 May 2018 15:43:08 +0300
parents 918bf90466e0
children cb1346b553aa
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/)
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
34 ->has_daemon('openssl')->plan(21);
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 {
1139
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
78 return 200 "body $ssl_client_i_dn";
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 {
1139
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
81 return 200 "body $ssl_client_s_dn";
1094
dd8f126afa32 Tests: client certificate time variables tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1093
diff changeset
82 }
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
83
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
84 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
85 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
86 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
87 }
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
88 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
89
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
90 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
91 listen 127.0.0.1:8081;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
92 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
93
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
94 # Special case for enabled "ssl" directive.
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
95
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
96 ssl on;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
97 ssl_session_cache builtin;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
98 ssl_session_timeout 1;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
99
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
100 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
101 return 200 "body $ssl_session_reused";
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 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
104
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
105 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
106 listen 127.0.0.1:8082 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
107 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
108
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
109 ssl_session_cache builtin:1000;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
110
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
111 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
112 return 200 "body $ssl_session_reused";
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 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
115
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
116 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
117 listen 127.0.0.1:8083 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
118 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
119
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
120 ssl_session_cache none;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
121
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
122 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
123 return 200 "body $ssl_session_reused";
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 }
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
126
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
127 server {
1276
490691c45b3f Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
128 listen 127.0.0.1:8084 ssl;
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
129 server_name localhost;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
130
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
131 ssl_session_cache off;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
132
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
133 location / {
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
134 return 200 "body $ssl_session_reused";
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
135 }
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 EOF
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 $t->write_file('openssl.conf', <<EOF);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 [ req ]
1116
8ef51dbb5d69 Tests: reduced OpenSSL default key length to 1024.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1100
diff changeset
143 default_bits = 1024
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 encrypt_key = no
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 distinguished_name = req_distinguished_name
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 [ req_distinguished_name ]
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 EOF
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 my $d = $t->testdir();
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
151 $t->write_file('ca.conf', <<EOF);
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
152 [ ca ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
153 default_ca = myca
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
154
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
155 [ myca ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
156 new_certs_dir = $d
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
157 database = $d/certindex
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
158 default_md = sha1
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
159 policy = myca_policy
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
160 serial = $d/certserial
1094
dd8f126afa32 Tests: client certificate time variables tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1093
diff changeset
161 default_days = 3
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
162
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
163 [ myca_policy ]
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
164 commonName = supplied
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
165 EOF
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
166
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
167 $t->write_file('certserial', '1000');
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
168 $t->write_file('certindex', '');
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
169
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
170 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
171 . "-config $d/openssl.conf -subj /CN=issuer/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
172 . "-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
173 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
174 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
175
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
176 system("openssl req -new "
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
177 . "-config $d/openssl.conf -subj /CN=subject/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
178 . "-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
179 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
180 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
181
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
182 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
183 . "-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
184 . "-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
185 . ">>$d/openssl.out 2>&1") == 0
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
186 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
187
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
188 foreach my $name ('localhost', 'inner') {
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
190 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1139
diff changeset
191 . "-out $d/$name.crt -keyout $d/$name.key "
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192 . ">>$d/openssl.out 2>&1") == 0
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
193 or die "Can't create certificate for $name: $!\n";
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
194 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
196 my $ctx = new IO::Socket::SSL::SSL_Context(
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
197 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
198 SSL_session_cache_size => 100);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
199
1324
918bf90466e0 Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1276
diff changeset
200 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
201 $t->run();
1324
918bf90466e0 Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1276
diff changeset
202 open STDERR, ">&", \*OLDERR;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
203
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
204 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
205
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
206 like(get('/reuse', 8085), qr/^body \.$/m, 'shared initial session');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
207 like(get('/reuse', 8085), qr/^body r$/m, 'shared session reused');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
208
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
209 like(get('/', 8081), qr/^body \.$/m, 'builtin initial session');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
210 like(get('/', 8081), qr/^body r$/m, 'builtin session reused');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
211
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
212 like(get('/', 8082), qr/^body \.$/m, 'builtin size initial session');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
213 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
214
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
215 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
216 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
217
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
218 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
219 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
220
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
221 # ssl certificate inheritance
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
222
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
223 my $s = get_ssl_socket($ctx, port(8081));
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
224 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN');
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
225
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
226 $s->close();
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
227
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
228 $s = get_ssl_socket($ctx, port(8085));
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
229 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
230
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
231 $s->close();
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
232
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
233 # session timeout
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
234
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
235 select undef, undef, undef, 2.1;
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
236
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
237 like(get('/', 8081), qr/^body \.$/m, 'session timeout');
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
238
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
239 # embedded variables
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
240
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
241 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
242 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
243 like(get('/cipher', 8085), qr/^body [\w-]+$/m, 'cipher');
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
244 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
245 like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol');
1139
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
246 like(cert('/issuer', 8085), qr!^body CN=issuer$!m, 'issuer');
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
247 like(cert('/subject', 8085), qr!^body CN=subject$!m, 'subject');
e7e968e3eb74 Tests: split ssl.t to run relevant tests on stable versions again.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1132
diff changeset
248
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
249 # 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
250
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
251 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
252 '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
253
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
254 ###############################################################################
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
255
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
256 sub get {
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
257 my ($uri, $port) = @_;
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
258 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
259 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
260 $s->close();
3d312b6a1a19 Tests: avoid $ssl_session_reused tests failure with OpenSSL 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
261 return $r;
1067
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
262 }
4606a2ec3d7c Tests: ssl.t cleanup, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
263
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
264 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
265 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
266 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
267 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
268 . "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
269 . "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
270 . "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
271 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
272 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
273 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
274 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
275 $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
276 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
277 }
f80176242a7e Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
278
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
279 sub cert {
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
280 my ($uri, $port) = @_;
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
281 my $s = get_ssl_socket(undef, port($port),
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
282 SSL_cert_file => "$d/subject.crt",
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
283 SSL_key_file => "$d/subject.key") or return;
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
284 http_get($uri, socket => $s);
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
285 }
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
286
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
287 sub get_ssl_socket {
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
288 my ($ctx, $port, %extra) = @_;
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
289 my $s;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
290
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
291 eval {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
292 local $SIG{ALRM} = sub { die "timeout\n" };
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
293 local $SIG{PIPE} = sub { die "sigpipe\n" };
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
294 alarm(2);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
295 $s = IO::Socket::SSL->new(
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
296 Proto => 'tcp',
664
97660514e518 Tests: more http ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 503
diff changeset
297 PeerAddr => '127.0.0.1',
952
e9064d691790 Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 664
diff changeset
298 PeerPort => $port,
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
299 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
300 SSL_reuse_ctx => $ctx,
1068
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
301 SSL_error_trap => sub { die $_[1] },
d0ec761774a5 Tests: client certificate issuer/subject variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1067
diff changeset
302 %extra
370
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
303 );
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
304 alarm(0);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
305 };
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 alarm(0);
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
307
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
308 if ($@) {
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309 log_in("died: $@");
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310 return undef;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
313 return $s;
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
314 }
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315
74cfe56c7b83 Tests: simple https tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
316 ###############################################################################