Mercurial > hg > nginx-tests
comparison stream_proxy_ssl_conf_command.t @ 1604:4be791074207
Tests: proxy_ssl_conf_command tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 23 Oct 2020 13:22:19 +0100 |
parents | |
children | e4e0695552ed |
comparison
equal
deleted
inserted
replaced
1603:8d2d37a4b48e | 1604:4be791074207 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for stream proxy to ssl backend, proxy_ssl_conf_command. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/stream stream_ssl stream_return/) | |
26 ->has_daemon('openssl'); | |
27 | |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 daemon off; | |
33 | |
34 events { | |
35 } | |
36 | |
37 stream { | |
38 server { | |
39 listen 127.0.0.1:8080; | |
40 proxy_pass 127.0.0.1:8081; | |
41 proxy_ssl on; | |
42 | |
43 proxy_ssl_certificate localhost.crt; | |
44 proxy_ssl_certificate_key localhost.key; | |
45 proxy_ssl_conf_command Certificate override.crt; | |
46 proxy_ssl_conf_command PrivateKey override.key; | |
47 } | |
48 | |
49 server { | |
50 listen 127.0.0.1:8081 ssl; | |
51 return $ssl_client_s_dn; | |
52 | |
53 ssl_certificate localhost.crt; | |
54 ssl_certificate_key localhost.key; | |
55 ssl_verify_client optional_no_ca; | |
56 } | |
57 } | |
58 | |
59 EOF | |
60 | |
61 $t->write_file('openssl.conf', <<EOF); | |
62 [ req ] | |
63 default_bits = 2048 | |
64 encrypt_key = no | |
65 distinguished_name = req_distinguished_name | |
66 [ req_distinguished_name ] | |
67 EOF | |
68 | |
69 my $d = $t->testdir(); | |
70 | |
71 foreach my $name ('localhost', 'override') { | |
72 system('openssl req -x509 -new ' | |
73 . "-config $d/openssl.conf -subj /CN=$name/ " | |
74 . "-out $d/$name.crt -keyout $d/$name.key " | |
75 . ">>$d/openssl.out 2>&1") == 0 | |
76 or die "Can't create certificate for $name: $!\n"; | |
77 } | |
78 | |
79 $t->write_file('index.html', ''); | |
80 $t->try_run('no proxy_ssl_conf_command')->plan(1); | |
81 | |
82 ############################################################################### | |
83 | |
84 like(http_get('/'), qr/CN=override/, 'Certificate'); | |
85 | |
86 ############################################################################### |