annotate mail_ssl_session_reuse.t @ 1861:7b7b64569f55

Tests: reworked mail SSL tests to use IO::Socket::SSL. Relevant infrastructure is provided in Test::Nginx::IMAP (and also POP3 and SMTP for completeness). This also ensures that SSL handshake and various read operations are guarded with timeouts.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 May 2023 18:07:08 +0300
parents ce4a06d72256
children f7f1f349dd26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
4 # (C) Maxim Dounin
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
5 # (C) Nginx, Inc.
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
6
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
7 # Tests for mail ssl module, session reuse.
1142
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
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
11 use warnings;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
12 use strict;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
13
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
14 use Test::More;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
15
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
17
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
18 use lib 'lib';
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
19 use Test::Nginx;
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
20 use Test::Nginx::IMAP;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
21
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 select STDERR; $| = 1;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
25 select STDOUT; $| = 1;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
26
1856
ce4a06d72256 Tests: SIGPIPE handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1832
diff changeset
27 local $SIG{PIPE} = 'IGNORE';
ce4a06d72256 Tests: SIGPIPE handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1832
diff changeset
28
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
29 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap socket_ssl_sslversion/)
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
30 ->has_daemon('openssl')->plan(7);
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
31
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
32 $t->write_file_expand('nginx.conf', <<'EOF');
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 %%TEST_GLOBALS%%
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
35
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
36 daemon off;
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
37
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
38 events {
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
39 }
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 mail {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
42 auth_http http://127.0.0.1:8080;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
43
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
44 ssl_certificate localhost.crt;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
45 ssl_certificate_key localhost.key;
1142
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 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
48 listen 127.0.0.1:8993 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
49 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
50 }
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
51
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
52 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
53 listen 127.0.0.1:8994 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
54 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
55
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
56 ssl_session_cache shared:SSL:1m;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
57 ssl_session_tickets on;
1142
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
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
60 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
61 listen 127.0.0.1:8995 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
62 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
63
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
64 ssl_session_cache shared:SSL:1m;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
65 ssl_session_tickets off;
1142
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
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
68 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
69 listen 127.0.0.1:8996 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
70 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
71
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
72 ssl_session_cache builtin;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
73 ssl_session_tickets off;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
74 }
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
75
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
76 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
77 listen 127.0.0.1:8997 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
78 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
79
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
80 ssl_session_cache builtin:1000;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
81 ssl_session_tickets off;
1142
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 {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
85 listen 127.0.0.1:8998 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
86 protocol imap;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
87
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
88 ssl_session_cache none;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
89 ssl_session_tickets off;
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
90 }
1148
44620036fedf Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1147
diff changeset
91
44620036fedf Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1147
diff changeset
92 server {
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
93 listen 127.0.0.1:8999 ssl;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
94 protocol imap;
1148
44620036fedf Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1147
diff changeset
95
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
96 ssl_session_cache off;
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
97 ssl_session_tickets off;
1148
44620036fedf Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1147
diff changeset
98 }
1142
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
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
101 EOF
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
102
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
103 $t->write_file('openssl.conf', <<EOF);
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
104 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1324
diff changeset
105 default_bits = 2048
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
106 encrypt_key = no
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
107 distinguished_name = req_distinguished_name
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
108 [ req_distinguished_name ]
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
109 EOF
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 my $d = $t->testdir();
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
112
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
113 foreach my $name ('localhost') {
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
114 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1148
diff changeset
115 . "-config $d/openssl.conf -subj /CN=$name/ "
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
116 . "-out $d/$name.crt -keyout $d/$name.key "
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
117 . ">>$d/openssl.out 2>&1") == 0
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
118 or die "Can't create certificate for $name: $!\n";
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
119 }
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
120
1145
f193664e06d8 Tests: remove unused http block in mail_ssl.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1142
diff changeset
121 $t->run();
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
122
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
123 ###############################################################################
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
124
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
125 # session reuse:
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
126 #
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
127 # - only tickets, the default
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
128 # - tickets and shared cache, should work always
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
129 # - only shared cache
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
130 # - only builtin cache
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
131 # - only builtin cache with explicitly configured size
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
132 # - only cache none
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
133 # - only cache off
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
134
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
135 TODO: {
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
136 local $TODO = 'no TLSv1.3 sessions, old Net::SSLeay'
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
137 if $Net::SSLeay::VERSION < 1.88 && test_tls13();
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
138 local $TODO = 'no TLSv1.3 sessions, old IO::Socket::SSL'
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
139 if $IO::Socket::SSL::VERSION < 2.061 && test_tls13();
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
140 local $TODO = 'no TLSv1.3 sessions in LibreSSL'
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
141 if $t->has_module('LibreSSL') && test_tls13();
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
142
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
143 is(test_reuse(8993), 1, 'tickets reused');
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
144 is(test_reuse(8994), 1, 'tickets and cache reused');
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
145
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
146 TODO: {
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
147 local $TODO = 'no TLSv1.3 session cache in BoringSSL'
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
148 if $t->has_module('BoringSSL') && test_tls13();
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
149
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
150 is(test_reuse(8995), 1, 'cache shared reused');
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
151 is(test_reuse(8996), 1, 'cache builtin reused');
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
152 is(test_reuse(8997), 1, 'cache builtin size reused');
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
153
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
154 }
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
155 }
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
156
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
157 is(test_reuse(8998), 0, 'cache none not reused');
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
158 is(test_reuse(8999), 0, 'cache off not reused');
1148
44620036fedf Tests: added starttls tests for smtp.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1147
diff changeset
159
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
160 ###############################################################################
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
161
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
162 sub test_tls13 {
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
163 my $s = Test::Nginx::IMAP->new(SSL => 1);
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
164 return ($s->socket()->get_sslversion_int() > 0x303);
1832
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
165 }
2e541778e5d8 Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1831
diff changeset
166
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
167 sub test_reuse {
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
168 my ($port) = @_;
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
169
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
170 my $s = Test::Nginx::IMAP->new(
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
171 PeerAddr => '127.0.0.1:' . port($port),
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
172 SSL => 1,
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
173 SSL_session_cache_size => 100
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
174 );
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
175 $s->read();
1831
f6d1f82f314b Tests: separate SSL session reuse tests in mail.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1826
diff changeset
176
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
177 $s = Test::Nginx::IMAP->new(
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
178 PeerAddr => '127.0.0.1:' . port($port),
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
179 SSL => 1,
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
180 SSL_reuse_ctx => $s->socket()
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
181 );
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
182
1861
7b7b64569f55 Tests: reworked mail SSL tests to use IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1856
diff changeset
183 return $s->socket()->get_session_reused();
1142
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
184 }
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
185
baeebac35a2e Tests: basic mail ssl tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
186 ###############################################################################