annotate stream_ssl_realip.t @ 1585:bff287fbf347

Tests: added proxy_cookie_domain/path tests with "off" parameter.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 23 Jul 2020 12:17:39 +0300
parents dbce8fb5f5f8
children f3ba4c74de31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for stream realip module, server side proxy protocol with ssl.
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 use Socket qw/ $CRLF /;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 BEGIN { use FindBin; chdir($FindBin::Bin); }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use lib 'lib';
1458
e95133e85798 Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
20 use Test::Nginx qw/ :DEFAULT http_end /;
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 ###############################################################################
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDERR; $| = 1;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 select STDOUT; $| = 1;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 eval { require IO::Socket::SSL; };
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 plan(skip_all => 'IO::Socket::SSL too old') if $@;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
1170
cf14cfe9ec8c Tests: dropped obsolete ipv6 prerequisite.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1168
diff changeset
32 my $t = Test::Nginx->new()->has(qw/stream stream_return stream_realip/)
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 ->has(qw/stream_ssl/)->has_daemon('openssl')
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 ->write_file_expand('nginx.conf', <<'EOF');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS%%
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 daemon off;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 events {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 stream {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 ssl_certificate_key localhost.key;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 ssl_certificate localhost.crt;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 server {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 listen 127.0.0.1:8083 proxy_protocol ssl;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 return $proxy_protocol_addr:$proxy_protocol_port;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 server {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 listen 127.0.0.1:8086 proxy_protocol ssl;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 listen [::1]:%%PORT_8086%% proxy_protocol ssl;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 return "$remote_addr:$remote_port:
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 $realip_remote_addr:$realip_remote_port";
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 set_real_ip_from ::1;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 set_real_ip_from 127.0.0.2;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 server {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 listen 127.0.0.1:8087;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 proxy_pass [::1]:%%PORT_8086%%;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 server {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 listen 127.0.0.1:8088 proxy_protocol ssl;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 listen [::1]:%%PORT_8088%% proxy_protocol ssl;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 return "$remote_addr:$remote_port:
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 $realip_remote_addr:$realip_remote_port";
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 set_real_ip_from 127.0.0.1;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 set_real_ip_from ::2;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 server {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 listen 127.0.0.1:8089;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 proxy_pass [::1]:%%PORT_8088%%;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 EOF
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 $t->write_file('openssl.conf', <<EOF);
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1458
diff changeset
87 default_bits = 2048
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 encrypt_key = no
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 distinguished_name = req_distinguished_name
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 [ req_distinguished_name ]
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 EOF
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 my $d = $t->testdir();
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 foreach my $name ('localhost') {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1190
diff changeset
97 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1190
diff changeset
98 . "-out $d/$name.crt -keyout $d/$name.key "
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 . ">>$d/openssl.out 2>&1") == 0
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 or die "Can't create certificate for $name: $!\n";
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102
1251
766bcbb632ee Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1220
diff changeset
103 $t->try_run('no inet6 support')->plan(6);
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 ###############################################################################
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 is(pp_get(8083, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 '192.0.2.1:1234', 'server');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 like(pp_get(8086, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server ipv6 realip - no match');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 like(pp_get(8087, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 qr/\Q192.0.2.1:1234:\E\s+\Q::1:\E\d+/, 'server ipv6 realip');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 like(pp_get(8088, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 qr/\Q192.0.2.1:1234:\E\s+\Q127.0.0.1:\E\d+/, 'server ipv4 realip');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 like(pp_get(8089, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 qr/^(::1:\d+):\s+\1$/, 'server ipv4 realip - no match');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 like(pp_get(8088, "PROXY UNKNOWN TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server unknown');
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 ###############################################################################
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 sub pp_get {
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 my ($port, $proxy) = @_;
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129
1458
e95133e85798 Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
130 my $s = IO::Socket::INET->new('127.0.0.1:' . port($port)) or return;
e95133e85798 Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
131 http($proxy, start => 1, socket => $s);
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132
1168
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
133 eval {
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
134 local $SIG{ALRM} = sub { die "timeout\n" };
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
135 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
136 alarm(8);
1458
e95133e85798 Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
137 IO::Socket::SSL->start_SSL($s,
1168
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
138 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
139 SSL_error_trap => sub { die $_[1] }
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
140 );
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
141 alarm(0);
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
142 };
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
143 alarm(0);
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
144
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
145 if ($@) {
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
146 log_in("died: $@");
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
147 return undef;
8821e405b91e Tests: handled SSL negotiation errors.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
148 }
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149
1458
e95133e85798 Tests: unbreak stream_ssl_realip.t with TLS 1.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1421
diff changeset
150 http_end($s);
1029
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 }
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152
21602616d8ee Tests: stream realip tests, listen proxy_protocol ssl tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 ###############################################################################