Mercurial > hg > nginx-tests
changeset 1168:8821e405b91e
Tests: handled SSL negotiation errors.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 20 Apr 2017 16:29:07 +0300 |
parents | 1e79a9613813 |
children | 518d1c865812 |
files | ssl_proxy_protocol.t stream_ssl_realip.t |
diffstat | 2 files changed, 32 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ssl_proxy_protocol.t Thu Apr 20 16:05:10 2017 +0300 +++ b/ssl_proxy_protocol.t Thu Apr 20 16:29:07 2017 +0300 @@ -153,10 +153,22 @@ my $s = http($proxy, start => 1); - IO::Socket::SSL->start_SSL($s, - SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), - SSL_error_trap => sub { die $_[1] } - ); + eval { + local $SIG{ALRM} = sub { die "timeout\n" }; + local $SIG{PIPE} = sub { die "sigpipe\n" }; + alarm(2); + IO::Socket::SSL->start_SSL($s, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), + SSL_error_trap => sub { die $_[1] } + ); + alarm(0); + }; + alarm(0); + + if ($@) { + log_in("died: $@"); + return undef; + } return http(<<EOF, socket => $s); GET $url HTTP/1.0
--- a/stream_ssl_realip.t Thu Apr 20 16:05:10 2017 +0300 +++ b/stream_ssl_realip.t Thu Apr 20 16:29:07 2017 +0300 @@ -131,10 +131,22 @@ my $s = stream(PeerPort => port($port)); $s->write($proxy); - IO::Socket::SSL->start_SSL($s->{_socket}, - SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), - SSL_error_trap => sub { die $_[1] } - ); + eval { + local $SIG{ALRM} = sub { die "timeout\n" }; + local $SIG{PIPE} = sub { die "sigpipe\n" }; + alarm(2); + IO::Socket::SSL->start_SSL($s->{_socket}, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), + SSL_error_trap => sub { die $_[1] } + ); + alarm(0); + }; + alarm(0); + + if ($@) { + log_in("died: $@"); + return undef; + } return $s->read(); }