Mercurial > hg > nginx-tests
changeset 1608:2f00ed2e0d1a
Tests: added test for SSL shutdown on lingering close.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 11 Nov 2020 10:45:26 +0000 |
parents | 0411d30859ad |
children | f3ba4c74de31 |
files | ssl.t |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ssl.t Tue Nov 10 18:45:10 2020 +0000 +++ b/ssl.t Wed Nov 11 10:45:26 2020 +0000 @@ -31,7 +31,7 @@ plan(skip_all => 'IO::Socket::SSL too old') if $@; my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/) - ->has_daemon('openssl')->plan(24); + ->has_daemon('openssl')->plan(25); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -298,6 +298,15 @@ my $r = http($req, socket => $s) || ""; is(() = $r =~ /(200 OK)/g, 1000, 'pipelined requests'); +# close_notify is sent before lingering close + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.5'); + +is(get_ssl_shutdown(8085), 1, 'ssl shutdown on lingering close'); + +} + ############################################################################### sub get { @@ -368,4 +377,18 @@ return $s; } +sub get_ssl_shutdown { + my ($port) = @_; + + my $s = IO::Socket::INET->new('127.0.0.1:' . port($port)); + my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); + my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); + Net::SSLeay::set_fd($ssl, fileno($s)); + Net::SSLeay::connect($ssl) or die("ssl connect"); + Net::SSLeay::write($ssl, 'GET /' . CRLF . 'extra'); + Net::SSLeay::read($ssl); + Net::SSLeay::set_shutdown($ssl, 1); + Net::SSLeay::shutdown($ssl); +} + ###############################################################################