diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-07-25 14:48:47 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-07-25 15:32:45 +0200 |
commit | 0dbee52febdb9cbb243612c94b1c765d821092ac (patch) | |
tree | 4154f63b0a5b6ecfb62926c68a28a03e95f9f02d /lib/handshake.c | |
parent | 10f83e36ed9213bb3e77922bdc15d5b8d64f3ffb (diff) | |
download | gnutls-0dbee52febdb9cbb243612c94b1c765d821092ac.tar.gz |
send_client_hello: don't override version after HRR is received
When a Hello Retry Request is received, do not set our (transient)
version to TLS1.2 on the second client hello. That's because both
peers have already negotiated TLS1.3.
This addresses issue with peers which may send a changecipherspec
message at this stage, which is now allowed when our version is
set to be TLS1.2. Introduced test suite using openssl and resumption
using HRR which reproduces the issue.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/handshake.c')
-rw-r--r-- | lib/handshake.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/handshake.c b/lib/handshake.c index 5feaed99fd..d0c0f9dc97 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -2049,13 +2049,15 @@ static int send_client_hello(gnutls_session_t session, int again) goto cleanup; } - /* Set the version we advertized as maximum - * (RSA uses it). - */ - set_adv_version(session, hver->major, hver->minor); - if (_gnutls_set_current_version(session, hver->id) < 0) { - ret = gnutls_assert_val(GNUTLS_E_UNSUPPORTED_VERSION_PACKET); - goto cleanup; + /* if we are replying to an HRR the version is already negotiated */ + if (!(session->internals.hsk_flags & HSK_HRR_RECEIVED) || !get_version(session)) { + /* Set the version we advertized as maximum + * (RSA uses it). */ + set_adv_version(session, hver->major, hver->minor); + if (_gnutls_set_current_version(session, hver->id) < 0) { + ret = gnutls_assert_val(GNUTLS_E_UNSUPPORTED_VERSION_PACKET); + goto cleanup; + } } if (session->internals.priorities->min_record_version != 0) { |