Mercurial > hg > nginx-tests
annotate stream_ssl_preread_alpn.t @ 1308:58fdd9515f81
Tests: fixed printing try_run() diagnostics.
Previously, error log path could point to junk on unsuccessful regex match.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 26 Mar 2018 14:27:57 +0300 |
parents | 23026106e439 |
children | 97c8280de681 |
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 { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 map $ssl_preread_alpn_protocols $name { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 "" 127.0.0.1:8093; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 default $ssl_preread_alpn_protocols; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 upstream foo { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server 127.0.0.1:8091; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 upstream bar { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 server 127.0.0.1:8092; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 upstream foo,bar { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server 127.0.0.1:8093; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 ssl_preread on; |
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 server { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 listen 127.0.0.1:8081; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 proxy_pass $name; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 ssl_certificate_key localhost.key; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 ssl_certificate localhost.crt; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 server { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 listen 127.0.0.1:8091 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 listen 127.0.0.1:8092 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 listen 127.0.0.1:8093 ssl; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 ssl_preread off; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 return $server_port; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
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 EOF |
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 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
|
77 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
|
78 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 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
|
80 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
|
81 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 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
|
83 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
|
84 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 $t->write_file('openssl.conf', <<EOF); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 [ req ] |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 default_bits = 1024 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 encrypt_key = no |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 distinguished_name = req_distinguished_name |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 [ req_distinguished_name ] |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 EOF |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $d = $t->testdir(); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 foreach my $name ('localhost') { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 system('openssl req -x509 -new ' |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 . "-config $d/openssl.conf -subj /CN=$name/ " |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 . "-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
|
99 . ">>$d/openssl.out 2>&1") == 0 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 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
|
101 } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
1307
23026106e439
Tests: unbreak stream_ssl_preread_alpn.t on OpenSSL < 1.0.2h.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1306
diff
changeset
|
103 $t->try_run('no ssl_preread_alpn_protocols')->plan(5); |
1306
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
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 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 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
|
108 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 is(get_ssl(8081, 'foo'), $p1, 'alpn'); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 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
|
111 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 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
|
113 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
|
114 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 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
|
116 |
1307
23026106e439
Tests: unbreak stream_ssl_preread_alpn.t on OpenSSL < 1.0.2h.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1306
diff
changeset
|
117 get_ssl(8081, ''); |
1306
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 ############################################################################### |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 sub get_ssl { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 my ($port, @alpn) = @_; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 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
|
124 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 eval { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 local $SIG{ALRM} = sub { die "timeout\n" }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 alarm(2); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 IO::Socket::SSL->start_SSL($s->{_socket}, |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 SSL_alpn_protocols => [ @alpn ], |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 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
|
132 SSL_error_trap => sub { die $_[1] } |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 ); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 alarm(0); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 }; |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 alarm(0); |
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 if ($@) { |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 log_in("died: $@"); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 return undef; |
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 |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 return $s->read(); |
5e9695bd370a
Tests: stream_ssl_preread module tests, ALPN preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 } |
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 ############################################################################### |