comparison ssl_crl.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
160 160
161 ############################################################################### 161 ###############################################################################
162 162
163 sub get { 163 sub get {
164 my ($port, $cert) = @_; 164 my ($port, $cert) = @_;
165 my $s = get_ssl_socket($port, $cert) or return; 165 http_get(
166 http_get('/t', socket => $s); 166 '/t', PeerAddr => '127.0.0.1:' . port($port),
167 } 167 SSL => 1,
168 168 SSL_cert_file => "$d/$cert.crt",
169 sub get_ssl_socket { 169 SSL_key_file => "$d/$cert.key"
170 my ($port, $cert) = @_; 170 );
171 my ($s);
172
173 eval {
174 local $SIG{ALRM} = sub { die "timeout\n" };
175 local $SIG{PIPE} = sub { die "sigpipe\n" };
176 alarm(8);
177 $s = IO::Socket::SSL->new(
178 Proto => 'tcp',
179 PeerAddr => '127.0.0.1',
180 PeerPort => port($port),
181 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
182 SSL_cert_file => "$d/$cert.crt",
183 SSL_key_file => "$d/$cert.key",
184 SSL_error_trap => sub { die $_[1] }
185 );
186 alarm(0);
187 };
188 alarm(0);
189
190 if ($@) {
191 log_in("died: $@");
192 return undef;
193 }
194
195 return $s;
196 } 171 }
197 172
198 ############################################################################### 173 ###############################################################################