comparison ssl.t @ 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 3b6b2667ece9
children 666d54ab5036
comparison
equal deleted inserted replaced
1607:0411d30859ad 1608:2f00ed2e0d1a
29 plan(skip_all => 'IO::Socket::SSL not installed') if $@; 29 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; 31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
32 32
33 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/) 33 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/)
34 ->has_daemon('openssl')->plan(24); 34 ->has_daemon('openssl')->plan(25);
35 35
36 $t->write_file_expand('nginx.conf', <<'EOF'); 36 $t->write_file_expand('nginx.conf', <<'EOF');
37 37
38 %%TEST_GLOBALS%% 38 %%TEST_GLOBALS%%
39 39
295 295
296 $req x= 1000; 296 $req x= 1000;
297 297
298 my $r = http($req, socket => $s) || ""; 298 my $r = http($req, socket => $s) || "";
299 is(() = $r =~ /(200 OK)/g, 1000, 'pipelined requests'); 299 is(() = $r =~ /(200 OK)/g, 1000, 'pipelined requests');
300
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 }
300 309
301 ############################################################################### 310 ###############################################################################
302 311
303 sub get { 312 sub get {
304 my ($uri, $port, $ctx) = @_; 313 my ($uri, $port, $ctx) = @_;
366 } 375 }
367 376
368 return $s; 377 return $s;
369 } 378 }
370 379
371 ############################################################################### 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
394 ###############################################################################