[PATCH 12 of 20] Tests: fixed ssl_session_ticket_key.t with LibreSSL and TLSv1.3

Maxim Dounin mdounin at mdounin.ru
Sat Mar 18 14:15:07 UTC 2023


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1679148620 -10800
#      Sat Mar 18 17:10:20 2023 +0300
# Node ID 25c625a731909efe2978b1fd497e9bdda9217a35
# Parent  7dec25ecd3db606258647bd2ce2bca15e793accb
Tests: fixed ssl_session_ticket_key.t with LibreSSL and TLSv1.3.

LibreSSL does not support session reuse with TLSv1.3.

diff --git a/ssl_session_ticket_key.t b/ssl_session_ticket_key.t
--- a/ssl_session_ticket_key.t
+++ b/ssl_session_ticket_key.t
@@ -96,6 +96,10 @@ select undef, undef, undef, 0.5;
 is(get_ticket_key_name(), $key, 'ticket key match');
 
 select undef, undef, undef, 2.5;
+
+local $TODO = 'no TLSv1.3 sessions in LibreSSL'
+	if $t->has_module('LibreSSL') && test_tls13();
+
 cmp_ok(get_ticket_key_name(), 'ne', $key, 'ticket key next');
 
 ###############################################################################
@@ -107,7 +111,7 @@ sub get_ticket_key_name {
 next:
 	# tag(10) | len{2} | OCTETSTRING(4) | len{2} | ticket(key_name|..)
 	$asn =~ /\xaa\x81($any)\x04\x81($any)($any{16})/g;
-	return if !defined $3;
+	return '' if !defined $3;
 	goto next if unpack("C", $1) - unpack("C", $2) != 3;
 	my $key = unpack "H*", $3;
 	Test::Nginx::log_core('||', "ticket key: $key");
@@ -126,6 +130,11 @@ EOF
 	Net::SSLeay::get_session($ssl);
 }
 
+sub test_tls13 {
+	my ($s, $ssl) = get_ssl_socket();
+	return (Net::SSLeay::version($ssl) > 0x303);
+}
+
 sub get_ssl_socket {
 	my $s = IO::Socket::INET->new('127.0.0.1:' . port(8080));
 	my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!");


More information about the nginx-devel mailing list