comparison mail_ssl.t @ 1147:796ed08cb215

Tests: simplified ssl_password_file tests in mail_ssl.t.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 07 Mar 2017 10:07:42 +0300
parents f193664e06d8
children 44620036fedf
comparison
equal deleted inserted replaced
1146:2634d0ef48d3 1147:796ed08cb215
49 mail { 49 mail {
50 ssl_certificate_key localhost.key; 50 ssl_certificate_key localhost.key;
51 ssl_certificate localhost.crt; 51 ssl_certificate localhost.crt;
52 ssl_session_tickets off; 52 ssl_session_tickets off;
53 53
54 # inherited by server "inherits" 54 ssl_password_file password;
55 ssl_password_file password_mail;
56 55
57 auth_http http://127.0.0.1:8080; # unused 56 auth_http http://127.0.0.1:8080; # unused
58 57
59 ssl_session_cache none; 58 ssl_session_cache none;
60 59
62 listen 127.0.0.1:8143; 61 listen 127.0.0.1:8143;
63 listen 127.0.0.1:8145 ssl; 62 listen 127.0.0.1:8145 ssl;
64 protocol imap; 63 protocol imap;
65 64
66 ssl_session_cache builtin; 65 ssl_session_cache builtin;
67 ssl_password_file password;
68 } 66 }
69 67
70 server { 68 server {
71 listen 127.0.0.1:8146 ssl; 69 listen 127.0.0.1:8146 ssl;
72 protocol imap; 70 protocol imap;
73 71
74 ssl_session_cache off; 72 ssl_session_cache off;
75 ssl_password_file password_many;
76 } 73 }
77 74
78 server { 75 server {
79 listen 127.0.0.1:8147; 76 listen 127.0.0.1:8147;
80 protocol imap; 77 protocol imap;
81 78
82 # Special case for enabled "ssl" directive. 79 # Special case for enabled "ssl" directive.
83 80
84 ssl on; 81 ssl on;
85 ssl_session_cache builtin:1000; 82 ssl_session_cache builtin:1000;
86 ssl_password_file password;
87 } 83 }
88 84
89 server { 85 server {
90 listen 127.0.0.1:8148 ssl; 86 listen 127.0.0.1:8148 ssl;
91 protocol imap; 87 protocol imap;
97 93
98 server { 94 server {
99 listen 127.0.0.1:8149; 95 listen 127.0.0.1:8149;
100 protocol imap; 96 protocol imap;
101 97
102 ssl_password_file password;
103 starttls on; 98 starttls on;
104 } 99 }
105 100
106 server { 101 server {
107 listen 127.0.0.1:8150; 102 listen 127.0.0.1:8150;
108 protocol imap; 103 protocol imap;
109 104
110 ssl_password_file password;
111 starttls only; 105 starttls only;
112 } 106 }
113 107
114 server { 108 server {
115 listen 127.0.0.1:8151; 109 listen 127.0.0.1:8151;
116 protocol pop3; 110 protocol pop3;
117 111
118 ssl_password_file password;
119 starttls on; 112 starttls on;
120 } 113 }
121 114
122 server { 115 server {
123 listen 127.0.0.1:8152; 116 listen 127.0.0.1:8152;
124 protocol pop3; 117 protocol pop3;
125 118
126 ssl_password_file password;
127 starttls only; 119 starttls only;
128 } 120 }
129 } 121 }
130 122
131 EOF 123 EOF
139 EOF 131 EOF
140 132
141 my $d = $t->testdir(); 133 my $d = $t->testdir();
142 134
143 foreach my $name ('localhost', 'inherits') { 135 foreach my $name ('localhost', 'inherits') {
144 system("openssl genrsa -out '$d/$name.key' -passout pass:$name " 136 system("openssl genrsa -out '$d/$name.key' -passout pass:localhost "
145 . "-aes128 1024 >>$d/openssl.out 2>&1") == 0 137 . "-aes128 1024 >>$d/openssl.out 2>&1") == 0
146 or die "Can't create private key: $!\n"; 138 or die "Can't create private key: $!\n";
147 system('openssl req -x509 -new ' 139 system('openssl req -x509 -new '
148 . "-config '$d/openssl.conf' -subj '/CN=$name/' " 140 . "-config '$d/openssl.conf' -subj '/CN=$name/' "
149 . "-out '$d/$name.crt' " 141 . "-out '$d/$name.crt' "
150 . "-key '$d/$name.key' -passin pass:$name" 142 . "-key '$d/$name.key' -passin pass:localhost"
151 . ">>$d/openssl.out 2>&1") == 0 143 . ">>$d/openssl.out 2>&1") == 0
152 or die "Can't create certificate for $name: $!\n"; 144 or die "Can't create certificate for $name: $!\n";
153 } 145 }
154 146
155 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); 147 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!");
156
157 $t->write_file('password', 'localhost'); 148 $t->write_file('password', 'localhost');
158 $t->write_file('password_many', "wrong$CRLF" . "localhost$CRLF");
159 $t->write_file('password_mail', 'inherits');
160
161 $t->run(); 149 $t->run();
162 150
163 ############################################################################### 151 ###############################################################################
164 152
165 # simple tests to ensure that nothing broke with ssl_password_file directive 153 # simple tests to ensure that nothing broke with ssl_password_file directive