Skip to content

Commit b31580c

Browse files
committed
Tests: added test for SSL shutdown on lingering close.
1 parent db086af commit b31580c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ssl.t

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
3131
plan(skip_all => 'IO::Socket::SSL too old') if $@;
3232

3333
my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/)
34-
->has_daemon('openssl')->plan(24);
34+
->has_daemon('openssl')->plan(25);
3535

3636
$t->write_file_expand('nginx.conf', <<'EOF');
3737
@@ -298,6 +298,15 @@ $req x= 1000;
298298
my $r = http($req, socket => $s) || "";
299299
is(() = $r =~ /(200 OK)/g, 1000, 'pipelined requests');
300300

301+
# close_notify is sent before lingering close
302+
303+
TODO: {
304+
local $TODO = 'not yet' unless $t->has_version('1.19.5');
305+
306+
is(get_ssl_shutdown(8085), 1, 'ssl shutdown on lingering close');
307+
308+
}
309+
301310
###############################################################################
302311

303312
sub get {
@@ -368,4 +377,18 @@ sub get_ssl_socket {
368377
return $s;
369378
}
370379

380+
sub get_ssl_shutdown {
381+
my ($port) = @_;
382+
383+
my $s = IO::Socket::INET->new('127.0.0.1:' . port($port));
384+
my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!");
385+
my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!");
386+
Net::SSLeay::set_fd($ssl, fileno($s));
387+
Net::SSLeay::connect($ssl) or die("ssl connect");
388+
Net::SSLeay::write($ssl, 'GET /' . CRLF . 'extra');
389+
Net::SSLeay::read($ssl);
390+
Net::SSLeay::set_shutdown($ssl, 1);
391+
Net::SSLeay::shutdown($ssl);
392+
}
393+
371394
###############################################################################

0 commit comments

Comments
 (0)