Mercurial > hg > nginx-tests
annotate mail_ssl.t @ 1652:21f511a7f5c3
Tests: compatibility with http2_max_requests removal.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 10 Feb 2021 15:13:22 +0300 |
parents | fd440d324700 |
children | 7bfa47410cc0 |
rev | line source |
---|---|
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
2 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
5 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
6 # Tests for mail ssl module. |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
7 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
9 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
11 use strict; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
12 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
14 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
16 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::IMAP; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx::POP3; |
1148
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
21 use Test::Nginx::SMTP; |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
22 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
24 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
27 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
28 eval { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
29 require Net::SSLeay; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
30 Net::SSLeay::load_error_strings(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
31 Net::SSLeay::SSLeay_add_ssl_algorithms(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
32 Net::SSLeay::randomize(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
33 }; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
34 plan(skip_all => 'Net::SSLeay not installed') if $@; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
35 |
1148
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
36 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap pop3 smtp/) |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
37 ->has_daemon('openssl')->plan(20); |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
38 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
39 $t->write_file_expand('nginx.conf', <<'EOF'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
40 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS%% |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
42 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
43 daemon off; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
44 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
45 events { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
46 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
47 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
48 mail { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
49 ssl_certificate_key localhost.key; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
50 ssl_certificate localhost.crt; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
51 ssl_session_tickets off; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
52 |
1147
796ed08cb215
Tests: simplified ssl_password_file tests in mail_ssl.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1145
diff
changeset
|
53 ssl_password_file password; |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
54 |
1145
f193664e06d8
Tests: remove unused http block in mail_ssl.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1142
diff
changeset
|
55 auth_http http://127.0.0.1:8080; # unused |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
56 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
57 ssl_session_cache none; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
58 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
59 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
60 listen 127.0.0.1:8143; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
61 listen 127.0.0.1:8145 ssl; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
62 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
63 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
64 ssl_session_cache builtin; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
66 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
68 listen 127.0.0.1:8146 ssl; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
69 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
70 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
71 ssl_session_cache off; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
74 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 listen 127.0.0.1:8147; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 # Special case for enabled "ssl" directive. |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
79 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
80 ssl on; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
81 ssl_session_cache builtin:1000; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
82 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
84 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 listen 127.0.0.1:8148 ssl; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 ssl_session_cache shared:SSL:1m; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
89 ssl_certificate_key inherits.key; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
90 ssl_certificate inherits.crt; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
91 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
92 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
93 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
94 listen 127.0.0.1:8149; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
95 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
96 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
97 starttls on; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
98 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
99 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
100 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
101 listen 127.0.0.1:8150; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
102 protocol imap; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
103 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
104 starttls only; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
105 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
106 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
107 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
108 listen 127.0.0.1:8151; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
109 protocol pop3; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
110 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
111 starttls on; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
112 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
113 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
114 server { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
115 listen 127.0.0.1:8152; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
116 protocol pop3; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
117 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
118 starttls only; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
119 } |
1148
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
120 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
121 server { |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
122 listen 127.0.0.1:8153; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
123 protocol smtp; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
124 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
125 starttls on; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
126 } |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
127 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
128 server { |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
129 listen 127.0.0.1:8154; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
130 protocol smtp; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
131 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
132 starttls only; |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
133 } |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
134 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
135 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
136 EOF |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
137 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
138 $t->write_file('openssl.conf', <<EOF); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
139 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1324
diff
changeset
|
140 default_bits = 2048 |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
141 encrypt_key = no |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
142 distinguished_name = req_distinguished_name |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
143 [ req_distinguished_name ] |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
144 EOF |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
145 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
146 my $d = $t->testdir(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
147 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
148 foreach my $name ('localhost', 'inherits') { |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1148
diff
changeset
|
149 system("openssl genrsa -out $d/$name.key -passout pass:localhost " |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1324
diff
changeset
|
150 . "-aes128 2048 >>$d/openssl.out 2>&1") == 0 |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
151 or die "Can't create private key: $!\n"; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
152 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1148
diff
changeset
|
153 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1148
diff
changeset
|
154 . "-out $d/$name.crt " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1148
diff
changeset
|
155 . "-key $d/$name.key -passin pass:localhost" |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
156 . ">>$d/openssl.out 2>&1") == 0 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
157 or die "Can't create certificate for $name: $!\n"; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
158 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
159 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
160 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
161 $t->write_file('password', 'localhost'); |
1324
918bf90466e0
Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
162 |
918bf90466e0
Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
163 open OLDERR, ">&", \*STDERR; close STDERR; |
1145
f193664e06d8
Tests: remove unused http block in mail_ssl.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1142
diff
changeset
|
164 $t->run(); |
1324
918bf90466e0
Tests: hide startup warnings about deprecated ssl.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
165 open STDERR, ">&", \*OLDERR; |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
166 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
167 ############################################################################### |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
168 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
169 # simple tests to ensure that nothing broke with ssl_password_file directive |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
170 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
171 my $s = Test::Nginx::IMAP->new(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
172 $s->ok('greeting'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
173 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
174 $s->send('1 AUTHENTICATE LOGIN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
175 $s->check(qr/\+ VXNlcm5hbWU6/, 'login'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
176 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
177 # ssl_session_cache |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
178 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
179 my ($ssl, $ses); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
180 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
181 ($s, $ssl) = get_ssl_socket(8145); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
182 $ses = Net::SSLeay::get_session($ssl); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
183 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
184 ($s, $ssl) = get_ssl_socket(8145, $ses); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
185 is(Net::SSLeay::session_reused($ssl), 1, 'builtin session reused'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
186 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
187 ($s, $ssl) = get_ssl_socket(8146); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
188 $ses = Net::SSLeay::get_session($ssl); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
189 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
190 ($s, $ssl) = get_ssl_socket(8146, $ses); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
191 is(Net::SSLeay::session_reused($ssl), 0, 'session not reused'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
192 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
193 ($s, $ssl) = get_ssl_socket(8147); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
194 $ses = Net::SSLeay::get_session($ssl); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
195 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
196 ($s, $ssl) = get_ssl_socket(8147, $ses); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
197 is(Net::SSLeay::session_reused($ssl), 1, 'builtin size session reused'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
198 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
199 ($s, $ssl) = get_ssl_socket(8148); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
200 $ses = Net::SSLeay::get_session($ssl); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
201 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
202 ($s, $ssl) = get_ssl_socket(8148, $ses); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
203 is(Net::SSLeay::session_reused($ssl), 1, 'shared session reused'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
204 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
205 # ssl_certificate inheritance |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
206 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
207 ($s, $ssl) = get_ssl_socket(8145); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
208 like(Net::SSLeay::dump_peer_certificate($ssl), qr/CN=localhost/, 'CN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
209 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
210 ($s, $ssl) = get_ssl_socket(8148); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
211 like(Net::SSLeay::dump_peer_certificate($ssl), qr/CN=inherits/, 'CN inner'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
212 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
213 # starttls imap |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
214 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
215 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8149)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
216 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
217 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
218 $s->send('1 AUTHENTICATE LOGIN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
219 $s->check(qr/\+ VXNlcm5hbWU6/, 'imap auth before startls on'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
220 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
221 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8149)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
222 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
223 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
224 $s->send('1 STARTTLS'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
225 $s->ok('imap starttls on'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
226 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
227 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8150)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
228 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
229 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
230 $s->send('1 AUTHENTICATE LOGIN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
231 $s->check(qr/^\S+ BAD/, 'imap auth before startls only'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
232 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
233 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8150)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
234 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
235 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
236 $s->send('1 STARTTLS'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
237 $s->ok('imap starttls only'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
238 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
239 # starttls pop3 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
240 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
241 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8151)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
242 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
243 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
244 $s->send('AUTH LOGIN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
245 $s->check(qr/\+ VXNlcm5hbWU6/, 'pop3 auth before startls on'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
246 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
247 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8151)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
248 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
249 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
250 $s->send('STLS'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
251 $s->ok('pop3 starttls on'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
252 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
253 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8152)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
254 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
255 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
256 $s->send('AUTH LOGIN'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
257 $s->check(qr/^-ERR/, 'pop3 auth before startls only'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
258 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
259 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8152)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
260 $s->read(); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
261 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
262 $s->send('STLS'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
263 $s->ok('pop3 starttls only'); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
264 |
1148
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
265 # starttls smtp |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
266 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
267 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8153)); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
268 $s->read(); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
269 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
270 $s->send('AUTH LOGIN'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
271 $s->check(qr/^334 VXNlcm5hbWU6/, 'smtp auth before startls on'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
272 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
273 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8153)); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
274 $s->read(); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
275 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
276 $s->send('STARTTLS'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
277 $s->ok('smtp starttls on'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
278 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
279 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8154)); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
280 $s->read(); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
281 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
282 $s->send('AUTH LOGIN'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
283 $s->check(qr/^5.. /, 'smtp auth before startls only'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
284 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
285 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8154)); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
286 $s->read(); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
287 |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
288 $s->send('STARTTLS'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
289 $s->ok('smtp starttls only'); |
44620036fedf
Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1147
diff
changeset
|
290 |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
291 ############################################################################### |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
292 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
293 sub get_ssl_socket { |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
294 my ($port, $ses) = @_; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
295 |
1621
fd440d324700
Tests: simplified get_ssl_socket() functions that use Net::SSLeay.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
296 my $s = IO::Socket::INET->new('127.0.0.1:' . port($port)); |
1142
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
297 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
298 Net::SSLeay::set_session($ssl, $ses) if defined $ses; |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
299 Net::SSLeay::set_fd($ssl, fileno($s)); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
300 Net::SSLeay::connect($ssl) or die("ssl connect"); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
301 return ($s, $ssl); |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
302 } |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
303 |
baeebac35a2e
Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
304 ############################################################################### |