Mercurial > hg > nginx-tests
diff ssl_certificate_chain.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 |
line wrap: on
line diff
--- a/ssl_certificate_chain.t +++ b/ssl_certificate_chain.t @@ -133,41 +133,27 @@ system("openssl ca -batch -config $d/ca. ############################################################################### -is(get_ssl_socket(port(8080)), undef, 'incomplete chain'); -ok(get_ssl_socket(port(8081)), 'intermediate'); -ok(get_ssl_socket(port(8082)), 'intermediate server'); +ok(!get_ssl_socket(8080), 'incomplete chain'); +ok(get_ssl_socket(8081), 'intermediate'); +ok(get_ssl_socket(8082), 'intermediate server'); ############################################################################### sub get_ssl_socket { my ($port) = @_; - my ($s, $verify); + my ($verify); - eval { - local $SIG{ALRM} = sub { die "timeout\n" }; - local $SIG{PIPE} = sub { die "sigpipe\n" }; - alarm(8); - $s = IO::Socket::SSL->new( - Proto => 'tcp', - PeerAddr => '127.0.0.1', - PeerPort => $port, - SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER(), - SSL_ca_file => "$d/root.crt", - SSL_verify_callback => sub { - my ($ok) = @_; - $verify = $ok; - return $ok; - }, - SSL_error_trap => sub { die $_[1] } - ); - alarm(0); - }; - alarm(0); - - if ($@) { - log_in("died: $@"); - return undef; - } + http( + '', PeerAddr => '127.0.0.1:' . port($port), start => 1, + SSL => 1, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER(), + SSL_ca_file => "$d/root.crt", + SSL_verify_callback => sub { + my ($ok) = @_; + $verify = $ok; + return $ok; + } + ); return $verify; }