Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Sergey Kandaurov
March 23, 2023 12:00PM
> On 23 Mar 2023, at 18:10, Maxim Dounin <mdounin@mdounin.ru> wrote:
>
> Hello!
>
> On Wed, Mar 22, 2023 at 12:57:56PM +0400, Sergey Kandaurov wrote:
>
>>> On 18 Mar 2023, at 18:14, Maxim Dounin <mdounin@mdounin.ru> wrote:
>>>
>>> # HG changeset patch
>>> # User Maxim Dounin <mdounin@mdounin.ru>
>>> # Date 1679105686 -10800
>>> # Sat Mar 18 05:14:46 2023 +0300
>>> # Node ID 86c394a226d2a7d463da7a1b7e88375c71c0c69b
>>> # Parent 3c9aa6c23fc836725b96cf056d218217a5a81603
>>> Tests: separate SSL session reuse tests.
>>>
>>> Instead of being mixed with generic SSL tests, session reuse variants
>>> are now tested in a separate file.
>>>
>>> In the generic SSL tests only basic session reuse is now tested,
>>> notably with session tickets enabled and a shared SSL session cache.
>>> This should make it possible to reuse sessions in all cases (except
>>> when it's not supported, such as with LibreSSL with TLSv1.3).
>>>
>>> Note that session reuse with tickets implies that $ssl_session_id
>>> is selected by the client and therefore is not available on the
>>> initial connection. Relevant test is modified to handle this.
>>>
>>> Further, BoringSSL does not use legacy session ID with TLSv1.3 even
>>> if it is sent by the client. In contrast, OpenSSL always generates
>>> an unique legacy session id, so it is available with TLSv1.3 even if
>>> session resumption does not work (such as with old Net::SSLeay and
>>> IO::Socket::SSL modules).
>>
>> Note that TLSv1.3 has only ticket based session resumption.
>> BoringSSL has a different notion on using legacy session IDs
>> in TLSv1.3, see tls13_create_session_with_ticket() in sources:
>>
>> // Historically, OpenSSL filled in fake session IDs for ticket-based sessions.
>> // Envoy's tests depend on this, although perhaps they shouldn't.
>> SHA256(CBS_data(&ticket), CBS_len(&ticket), session->session_id);
>>
>> Later, SSL_SESSION_get_id() was additionally annotated in ssl.h:
>>
>> // As a workaround for some broken applications, BoringSSL sometimes synthesizes
>> // arbitrary session IDs for non-ID-based sessions. This behavior may be
>> // removed in the future.
>>
>> As for TLSv1.3 server context, BoringSSL doesn't seem to use "session ID"
>> besides echoing the client's legacy_session_id field content in the
>> legacy_session_id_echo field of ServerHello/HRR during handshake,
>> as mandated in RFC 8446, 4.1.3. So it doesn't settle in the session.
>
> Yes, that's basically what "BoringSSL does not use legacy session
> ID with TLSv1.3..." sentence describes.
>
>>>
>>> diff --git a/ssl.t b/ssl.t
>>> --- a/ssl.t
>>> +++ b/ssl.t
>>> @@ -31,7 +31,7 @@ eval { IO::Socket::SSL::SSL_VERIFY_NONE(
>>> 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(28);
>>> + ->has_daemon('openssl')->plan(21);
>>>
>>> $t->write_file_expand('nginx.conf', <<'EOF');
>>>
>>> @@ -47,7 +47,6 @@ http {
>>>
>>> ssl_certificate_key localhost.key;
>>> ssl_certificate localhost.crt;
>>> - ssl_session_tickets off;
>>>
>>> log_format ssl $ssl_protocol;
>>>
>>> @@ -59,6 +58,7 @@ http {
>>> ssl_certificate_key inner.key;
>>> ssl_certificate inner.crt;
>>> ssl_session_cache shared:SSL:1m;
>>> + ssl_session_tickets on;
>>> ssl_verify_client optional_no_ca;
>>>
>>> keepalive_requests 1000;
>>> @@ -100,57 +100,11 @@ http {
>>> }
>>>
>>> server {
>>> - listen 127.0.0.1:8081;
>>> - server_name localhost;
>>> -
>>> - # Special case for enabled "ssl" directive.
>>> -
>>> - ssl on;
>>
>> Removing tests for the "ssl" legacy directive doesn't feel right
>> now and is out of scope of this change. Please put this back.
>> Not being able to test it is fragile and can be left silently
>> broken, especially with the upcoming quic merge.
>
> It used to be tested as a side effect of session reuse tests, and
> hence it is now gone.

You are correct, yet it's useful to have it in some sort.

> It is also tested at least in
> ssl_reject_handshake.t, so I tend to think it is enough.
>

It is, though not very useful, at least now.
Currently the tested configuration in ssl_reject_handshake.t is
supplemented with "listen .. ssl" in adjacent virtual servers.
If the "ssl" directive gets broken and e.g. will stop doing its work,
the SSL mode will remain enabled across servers of the listening socket,
so this may be left unnoticed.
To make it more useful, we can remove "listen .. ssl" on virtual servers.

# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1679586784 -14400
# Thu Mar 23 19:53:04 2023 +0400
# Node ID 938f2657257c24ac2ceb8df39536d330bcc03930
# Parent 5abbc8e2d39dfda3913939a6ae293744f5f80933
Tests: removed ssl from virtual servers in ssl_reject_handshake.t.

In particular, this allows to test that the "ssl" directive actually works.

diff --git a/ssl_reject_handshake.t b/ssl_reject_handshake.t
--- a/ssl_reject_handshake.t
+++ b/ssl_reject_handshake.t
@@ -59,8 +59,8 @@ http {
}

server {
- listen 127.0.0.1:8080 ssl;
- listen 127.0.0.1:8081 ssl;
+ listen 127.0.0.1:8080;
+ listen 127.0.0.1:8081;
server_name virtual;

ssl_certificate localhost.crt;
@@ -76,12 +76,12 @@ http {
}

server {
- listen 127.0.0.1:8082 ssl;
+ listen 127.0.0.1:8082;
server_name virtual1;
}

server {
- listen 127.0.0.1:8082 ssl;
+ listen 127.0.0.1:8082;
server_name virtual2;

ssl_reject_handshake on;

BTW, the old documentation on the "ssl" directive stated that it
"Enables the HTTPS protocol for the given *virtual* server", though
it appears to be rather opposite (i.e. for the default one).

>> On the other hand, I'm fine with finally removing this directive.
>> It was made obsolete in version 1.15.0, released on 05 Jun 2018,
>> with the "listen .. ssl" upgrade path available back to 0.7.14,
>> released on 01 Sep 2008.
>
> I think we'll consider this in 1.25.x branch.
>
> [..]
>>> server_name localhost;
>>>
>>> ssl_session_cache shared:SSL:1m;
>>> + ssl_session_tickets on;
>>> ssl_session_timeout 1;
>>>
>>> location / {
>>> @@ -216,59 +170,34 @@ foreach my $name ('localhost', 'inner')
>>> or die "Can't create certificate for $name: $!\n";
>>> }
>>>
>>> -# suppress deprecation warning
>>> -
>>> -open OLDERR, ">&", \*STDERR; close STDERR;
>>> $t->run();
>>> -open STDERR, ">&", \*OLDERR;
>>>
>>> ###############################################################################
>>>
>>> -my $ctx;
>>> +# ssl session reuse
>>>
>>> -SKIP: {
>>> -skip 'no TLS 1.3 sessions', 6 if get('/protocol', 8085) =~ /TLSv1.3/
>>> - && ($Net::SSLeay::VERSION < 1.88 || $IO::Socket::SSL::VERSION < 2.061);
>>> +my $ctx = get_ssl_context();
>>>
>>> -$ctx = get_ssl_context();
>>> +like(get('/', 8085, $ctx), qr/^body \.$/m, 'session');
>>>
>>> -like(get('/', 8085, $ctx), qr/^body \.$/m, 'cache shared');
>>> -like(get('/', 8085, $ctx), qr/^body r$/m, 'cache shared reused');
>>> -
>>> -$ctx = get_ssl_context();
>>> +TODO: {
>>> +local $TODO = 'no TLSv1.3 sessions, old Net::SSLeay'
>>> + if $Net::SSLeay::VERSION < 1.88 && test_tls13();
>>> +local $TODO = 'no TLSv1.3 sessions, old IO::Socket::SSL'
>>> + if $IO::Socket::SSL::VERSION < 2.061 && test_tls13();
>>
>> Not sure why do you convert this to TODO.
>>
>> TODO blocks are used for something we control or able to fix.
>> SSL libraries are not something like that, so using SKIP there
>> is more appropriate and follows other platform-specific tests.
>> Besides that, TODOs plagues diagnostic output for no purpose.
>>
>> See also Test::More documentation:
>>
>> When do I use SKIP vs. TODO?
>> If it's something the user might not be able to do, use SKIP. This
>> includes optional modules that aren't installed, running under an OS
>> that doesn't have some feature (like "fork()" or symlinks), or maybe
>> you need an Internet connection and one isn't available.
>>
>> If it's something the programmer hasn't done yet, use TODO. This is
>> for any code you haven't written yet, or bugs you have yet to fix,
>> but want to put tests in your testing script (always a good idea).
>
> As you can see from the Test::More documentation, the main
> distinction is: SKIP is to be used when something cannot be
> tested, and TODO is to use when something doesn't work (but we can
> test it).
>
> In this particular case, things can be tested - but tests will
> fail due to lack of support in IO::Socket::SSL / Net::SSLeay.
>
> Immediate benefits of using TODO here is that a) test output
> provides good indication of what actually happens with these
> module versions (that is, it does not unexpectedly die or
> segfault, but session reuse does not work), b) tests are actually
> run and it can be easily spotted if they unexpectedly succeed, and
> c) it combines nicely with LibreSSL / BoringSSL TODOs (which are
> TODO for similar reasons, see the following patches).
>
> As the code in question is not under our control, it might be good
> enough to use SKIP instead of TODO (and the patch series does this
> at least once). But I tend to think that at least in case of
> LibreSSL it would be much better to use TODOs, so we'll be able to
> see when things are finally fixed in LibreSSL - I would expect
> this to happen in a foreseeable future.
>

Ok, I am partially agree with you (item "a" is the most prominent).
Let's leave TODOs.

--
Sergey Kandaurov
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 00 of 20] tests suite fixes for TLSv1.3

Maxim Dounin 535 March 18, 2023 10:18AM

[PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Maxim Dounin 154 March 18, 2023 10:18AM

Re: [PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Sergey Kandaurov 130 March 22, 2023 05:22AM

Re: [PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Maxim Dounin 123 March 23, 2023 10:18AM

Re: [PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Sergey Kandaurov 145 March 22, 2023 05:48AM

Re: [PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Maxim Dounin 129 March 23, 2023 10:16AM

Re: [PATCH 03 of 20] Tests: separate SSL session reuse tests in mail

Sergey Kandaurov 125 March 23, 2023 12:00PM

[PATCH 01 of 20] Tests: separate SSL session reuse tests

Maxim Dounin 203 March 18, 2023 10:18AM

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Sergey Kandaurov 190 March 22, 2023 04:58AM

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Maxim Dounin 131 March 23, 2023 10:12AM

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Sergey Kandaurov 123 March 23, 2023 12:00PM

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Maxim Dounin 172 March 23, 2023 01:26PM

Re: [PATCH 01 of 20] Tests: separate SSL session reuse tests

Sergey Kandaurov 189 March 24, 2023 08:40AM

[PATCH 08 of 20] Tests: enabled session reuse via TLS session tickets

Maxim Dounin 131 March 18, 2023 10:20AM

[PATCH 07 of 20] Tests: BoringSSL does not provide session ids with TLSv1.3

Maxim Dounin 139 March 18, 2023 10:20AM

[PATCH 09 of 20] Tests: restored proper port numbers in ssl_sni_sessions.t

Maxim Dounin 133 March 18, 2023 10:20AM

[PATCH 10 of 20] Tests: disabled ssl_sni_sessions.t with LibreSSL and BoringSSL

Maxim Dounin 149 March 18, 2023 10:20AM

[PATCH 05 of 20] Tests: separate SSL session reuse tests in stream

Maxim Dounin 145 March 18, 2023 10:20AM

Re: [PATCH 05 of 20] Tests: separate SSL session reuse tests in stream

Sergey Kandaurov 141 March 22, 2023 05:56AM

Re: [PATCH 05 of 20] Tests: separate SSL session reuse tests in stream

Maxim Dounin 123 March 23, 2023 10:18AM

[PATCH 06 of 20] Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail

Maxim Dounin 132 March 18, 2023 10:20AM

Re: [PATCH 06 of 20] Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail

Sergey Kandaurov 129 March 22, 2023 06:00AM

Re: [PATCH 06 of 20] Tests: LibreSSL and BoringSSL session reuse with TLSv1.3 in mail

Maxim Dounin 119 March 23, 2023 10:18AM

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

Maxim Dounin 114 March 18, 2023 10:20AM

[PATCH 13 of 20] Tests: fixed ssl_sni.t with LibreSSL and TLSv1.3

Maxim Dounin 171 March 18, 2023 10:20AM

[PATCH 11 of 20] Tests: fixed proxy_ssl.t with LibreSSL and TLSv1.3

Maxim Dounin 161 March 18, 2023 10:20AM

[PATCH 14 of 20] Tests: LibreSSL certificate negotiation with TLSv1.3

Maxim Dounin 200 March 18, 2023 10:20AM

[PATCH 15 of 20] Tests: LibreSSL does not send CA lists with TLSv1.3

Maxim Dounin 161 March 18, 2023 10:20AM

Re: [PATCH 15 of 20] Tests: LibreSSL does not send CA lists with TLSv1.3

Sergey Kandaurov 145 March 22, 2023 06:40AM

[PATCH 16 of 20] Tests: fixed stream_proxy_ssl.t with LibreSSL and TLSv1.3

Maxim Dounin 193 March 18, 2023 10:20AM

[PATCH 18 of 20] Tests: cleaned up ssl_ocsp.t

Maxim Dounin 161 March 18, 2023 10:20AM

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

Maxim Dounin 166 March 18, 2023 10:20AM

Re: [PATCH 20 of 20] Tests: fixed ssl_ocsp.t with LibreSSL and TLSv1.3

Sergey Kandaurov 153 March 22, 2023 07:12AM

Re: [PATCH 20 of 20] Tests: fixed ssl_ocsp.t with LibreSSL and TLSv1.3

Maxim Dounin 135 March 23, 2023 10:20AM

[PATCH 19 of 20] Tests: removed multiple server certificates from ssl_ocsp.t

Maxim Dounin 150 March 18, 2023 10:20AM

Re: [PATCH 19 of 20] Tests: removed multiple server certificates from ssl_ocsp.t

Sergey Kandaurov 136 March 22, 2023 07:06AM

Re: [PATCH 19 of 20] Tests: removed multiple server certificates from ssl_ocsp.t

Maxim Dounin 127 March 23, 2023 10:18AM

[PATCH 17 of 20] Tests: fixed stream_ssl_variables.t.t with LibreSSL and TLSv1.3

Maxim Dounin 139 March 18, 2023 10:20AM

Re: [PATCH 00 of 20] tests suite fixes for TLSv1.3

Sergey Kandaurov 120 March 22, 2023 07:44AM

Re: [PATCH 00 of 20] tests suite fixes for TLSv1.3

Maxim Dounin 144 March 23, 2023 10:20AM

Re: [PATCH 00 of 20] tests suite fixes for TLSv1.3

Sergey Kandaurov 120 March 23, 2023 12:02PM

Re: [PATCH 00 of 20] tests suite fixes for TLSv1.3

Maxim Dounin 117 March 23, 2023 12:54PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 315
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready