Mercurial > hg > nginx-tests
comparison ssl_verify_depth.t @ 1866:a797d7428fa5
Tests: simplified http SSL tests with IO::Socket::SSL.
The http SSL tests which previously used IO::Socket::SSL were converted
to use improved IO::Socket::SSL infrastructure in Test::Nginx.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:19 +0300 |
parents | cdcd75657e52 |
children | 0b5ec15c62ed |
comparison
equal
deleted
inserted
replaced
1865:0e1865aa9b33 | 1866:a797d7428fa5 |
---|---|
170 | 170 |
171 ############################################################################### | 171 ############################################################################### |
172 | 172 |
173 sub get { | 173 sub get { |
174 my ($port, $cert) = @_; | 174 my ($port, $cert) = @_; |
175 my $s = get_ssl_socket($port, $cert) or return; | 175 http_get( |
176 http_get("/t?$cert", socket => $s); | 176 "/t?$cert", |
177 } | 177 PeerAddr => '127.0.0.1:' . port($port), |
178 | 178 SSL => 1, |
179 sub get_ssl_socket { | 179 SSL_cert_file => "$d/$cert.crt", |
180 my ($port, $cert) = @_; | 180 SSL_key_file => "$d/$cert.key" |
181 my ($s); | 181 ); |
182 | |
183 eval { | |
184 local $SIG{ALRM} = sub { die "timeout\n" }; | |
185 local $SIG{PIPE} = sub { die "sigpipe\n" }; | |
186 alarm(8); | |
187 $s = IO::Socket::SSL->new( | |
188 Proto => 'tcp', | |
189 PeerAddr => '127.0.0.1', | |
190 PeerPort => port($port), | |
191 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), | |
192 SSL_cert_file => "$d/$cert.crt", | |
193 SSL_key_file => "$d/$cert.key", | |
194 SSL_error_trap => sub { die $_[1] } | |
195 ); | |
196 alarm(0); | |
197 }; | |
198 alarm(0); | |
199 | |
200 if ($@) { | |
201 log_in("died: $@"); | |
202 return undef; | |
203 } | |
204 | |
205 return $s; | |
206 } | 182 } |
207 | 183 |
208 ############################################################################### | 184 ############################################################################### |