Mercurial > hg > nginx-tests
annotate stream_ssl_preread_alpn.t @ 1783:95ba1e704b7b
Tests: fixed version check for tests added in bd21a4a7c9f5.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 04 Aug 2022 09:41:44 -0700 |
parents | f3ba4c74de31 |
children | cdcd75657e52 |
rev | line source |
---|---|
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream_ssl_preread module, ALPN preread. |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::Stream qw/ stream /; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/stream stream_map stream_ssl_preread/) |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has(qw/stream_ssl stream_return/)->has_daemon('openssl') |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 stream { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1488
diff
changeset
|
38 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1488
diff
changeset
|
39 |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 map $ssl_preread_alpn_protocols $name { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 "" 127.0.0.1:8093; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 default $ssl_preread_alpn_protocols; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 upstream foo { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server 127.0.0.1:8091; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 upstream bar { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 server 127.0.0.1:8092; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 upstream foo,bar { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server 127.0.0.1:8093; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 ssl_preread on; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 listen 127.0.0.1:8081; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 proxy_pass $name; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 ssl_certificate_key localhost.key; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 ssl_certificate localhost.crt; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 server { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 listen 127.0.0.1:8091 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 listen 127.0.0.1:8092 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 listen 127.0.0.1:8093 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 ssl_preread off; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 return $server_port; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 EOF |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 eval { require IO::Socket::SSL; die if $IO::Socket::SSL::VERSION < 1.56; }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 plan(skip_all => 'IO::Socket::SSL version >= 1.56 required') if $@; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 eval { IO::Socket::SSL->can_alpn() or die; }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 plan(skip_all => 'IO::Socket::SSL with OpenSSL ALPN support required') if $@; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 eval { exists &Net::SSLeay::P_alpn_selected or die; }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 plan(skip_all => 'Net::SSLeay with OpenSSL ALPN support required') if $@; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1307
diff
changeset
|
87 $t->plan(5); |
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1307
diff
changeset
|
88 |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 $t->write_file('openssl.conf', <<EOF); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
91 default_bits = 2048 |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 encrypt_key = no |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 distinguished_name = req_distinguished_name |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 [ req_distinguished_name ] |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 EOF |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 my $d = $t->testdir(); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 foreach my $name ('localhost') { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 system('openssl req -x509 -new ' |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 . "-config $d/openssl.conf -subj /CN=$name/ " |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 . "-out $d/$name.crt -keyout $d/$name.key " |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 . ">>$d/openssl.out 2>&1") == 0 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 or die "Can't create certificate for $name: $!\n"; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1307
diff
changeset
|
107 $t->run(); |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 ############################################################################### |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 my ($p1, $p2, $p3) = (port(8091), port(8092), port(8093)); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 is(get_ssl(8081, 'foo'), $p1, 'alpn'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 is(get_ssl(8081, 'foo'), $p1, 'alpn again'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 is(get_ssl(8081, 'bar'), $p2, 'alpn 2'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 is(get_ssl(8081, 'bar'), $p2, 'alpn 2 again'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 is(get_ssl(8081, 'foo', 'bar'), $p3, 'alpn many'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
1307
23026106e439
Tests: unbreak stream_ssl_preread_alpn.t on OpenSSL < 1.0.2h.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1306
diff
changeset
|
121 get_ssl(8081, ''); |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 ############################################################################### |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 sub get_ssl { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 my ($port, @alpn) = @_; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 my $s = stream('127.0.0.1:' . port($port)); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 eval { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 local $SIG{ALRM} = sub { die "timeout\n" }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 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
|
132 alarm(8); |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 IO::Socket::SSL->start_SSL($s->{_socket}, |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 SSL_alpn_protocols => [ @alpn ], |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 SSL_error_trap => sub { die $_[1] } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 ); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 alarm(0); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 alarm(0); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 if ($@) { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 log_in("died: $@"); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 return undef; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 return $s->read(); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 ############################################################################### |