comparison ssl_ocsp.t @ 1846:9d98c2ad3126

Tests: cleaned up ssl_ocsp.t. Fixed verbose logging, added $SIG{PIPE} handling to avoid hangs if the server closes connection, fixed SKIP message for BoringSSL.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 23 Mar 2023 19:50:24 +0300
parents 5ac6efbe5552
children a9704b9ed7a2
comparison
equal deleted inserted replaced
1845:65b1dd07c0e4 1846:9d98c2ad3126
41 }; 41 };
42 plan(skip_all => 'Net::SSLeay with OpenSSL SNI support required') if $@; 42 plan(skip_all => 'Net::SSLeay with OpenSSL SNI support required') if $@;
43 43
44 my $t = Test::Nginx->new()->has(qw/http http_ssl sni/)->has_daemon('openssl'); 44 my $t = Test::Nginx->new()->has(qw/http http_ssl sni/)->has_daemon('openssl');
45 45
46 plan(skip_all => 'no OCSP stapling') if $t->has_module('BoringSSL'); 46 plan(skip_all => 'no OCSP support in BoringSSL')
47 if $t->has_module('BoringSSL');
47 48
48 $t->write_file_expand('nginx.conf', <<'EOF'); 49 $t->write_file_expand('nginx.conf', <<'EOF');
49 50
50 %%TEST_GLOBALS%% 51 %%TEST_GLOBALS%%
51 52
414 $type = 'PSS' if $type eq 'RSA' && $version > 0x0303; 415 $type = 'PSS' if $type eq 'RSA' && $version > 0x0303;
415 my ($s, $ssl) = get_ssl_socket($type, $cert, %extra); 416 my ($s, $ssl) = get_ssl_socket($type, $cert, %extra);
416 my $cipher = Net::SSLeay::get_cipher($ssl); 417 my $cipher = Net::SSLeay::get_cipher($ssl);
417 Test::Nginx::log_core('||', "cipher: $cipher"); 418 Test::Nginx::log_core('||', "cipher: $cipher");
418 my $host = $extra{sni} ? $extra{sni} : 'localhost'; 419 my $host = $extra{sni} ? $extra{sni} : 'localhost';
420 local $SIG{PIPE} = 'IGNORE';
421 log_out("GET /serial HTTP/1.0\nHost: $host\n\n");
419 Net::SSLeay::write($ssl, "GET /serial HTTP/1.0\nHost: $host\n\n"); 422 Net::SSLeay::write($ssl, "GET /serial HTTP/1.0\nHost: $host\n\n");
420 my $r = Net::SSLeay::read($ssl); 423 my $r = Net::SSLeay::read($ssl);
421 Test::Nginx::log_core($r); 424 log_in($r);
422 $s->close(); 425 $s->close();
423 return $r unless wantarray(); 426 return $r unless wantarray();
424 return ($s, $ssl); 427 return ($s, $ssl);
425 } 428 }
426 429
494 my $headers = ''; 497 my $headers = '';
495 my $uri = ''; 498 my $uri = '';
496 my $resp; 499 my $resp;
497 500
498 while (<$client>) { 501 while (<$client>) {
502 Test::Nginx::log_core('||', $_);
499 $headers .= $_; 503 $headers .= $_;
500 last if (/^\x0d?\x0a?$/); 504 last if (/^\x0d?\x0a?$/);
501 } 505 }
502 506
503 $uri = $1 if $headers =~ /^\S+\s+\/([^ ]+)\s+HTTP/i; 507 $uri = $1 if $headers =~ /^\S+\s+\/([^ ]+)\s+HTTP/i;