Do not wait for server close-notify on TLS close

Resolves: RHEL-100407
This commit is contained in:
Tomas Korbar 2025-07-02 14:03:07 +02:00
parent 80c188d152
commit d80659120a
2 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,6 @@
commit 6ad7c887da762079000b23d0a890ed7ad366330f
commit 94ee6107a6ff5410666000fdb744aafff3d47af8
Author: Tomas Korbar <tkorbar@redhat.com>
Date: Thu Jun 26 10:08:07 2025 +0200
Date: Wed Jul 2 14:00:35 2025 +0200
Ensure close-notify is sent on end of TLS connection
@ -106,7 +106,7 @@ index d3cf7f0..8915066 100644
#endif
diff --git a/src/lftp_ssl.cc b/src/lftp_ssl.cc
index 89421ee..f83828d 100644
index 89421ee..3507e9c 100644
--- a/src/lftp_ssl.cc
+++ b/src/lftp_ssl.cc
@@ -48,6 +48,7 @@ lftp_ssl_base::lftp_ssl_base(int fd1,handshake_mode_t m,const char *h)
@ -117,7 +117,7 @@ index 89421ee..f83828d 100644
handshake_mode=m;
fatal=false;
cert_error=false;
@@ -350,10 +351,24 @@ void lftp_ssl_gnutls::load_keys()
@@ -350,10 +351,30 @@ void lftp_ssl_gnutls::load_keys()
Log::global->Format(9, "Loaded %d CRLs\n", res);
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
}
@ -129,11 +129,17 @@ index 89421ee..f83828d 100644
- gnutls_bye(session,GNUTLS_SHUT_RDWR); // FIXME - E_AGAIN
+ int res;
+ if(handshake_done) {
+ res = gnutls_bye(session,GNUTLS_SHUT_WR);
+ res = gnutls_bye(session,GNUTLS_SHUT_RDWR);
+ if (res == GNUTLS_E_SUCCESS) {
+ goodbye_done = true;
+ return DONE;
+ } else if (res == GNUTLS_E_AGAIN || res == GNUTLS_E_INTERRUPTED) {
+ /* In ideal world we would not need this if, but windows does not
+ * send close-notify, so do not wait on server close-notify */
+ if (gnutls_record_get_direction(session) == 0) {
+ goodbye_done = true;
+ return DONE;
+ }
+ return RETRY;
+ }
+ fatal=check_fatal(res);
@ -145,7 +151,7 @@ index 89421ee..f83828d 100644
}
lftp_ssl_gnutls::~lftp_ssl_gnutls()
{
@@ -854,10 +869,23 @@ void lftp_ssl_openssl::load_keys()
@@ -854,10 +875,23 @@ void lftp_ssl_openssl::load_keys()
}
}
}

View File

@ -1,7 +1,7 @@
Summary: A sophisticated file transfer program
Name: lftp
Version: 4.9.2
Release: 18%{?dist}
Release: 19%{?dist}
License: GPL-3.0-or-later
Source0: http://lftp.yar.ru/ftp/%{name}-%{version}.tar.xz
URL: http://lftp.yar.ru/
@ -100,6 +100,10 @@ rm -r $RPM_BUILD_ROOT%{_datadir}/lftp
%{_datadir}/icons/hicolor/*/apps/*
%changelog
* Wed Jul 02 2025 Tomas Korbar <tkorbar@redhat.com> - 4.9.2-19
- Do not wait for server close-notify on TLS close
- Resolves: RHEL-100407
* Thu Jun 26 2025 Tomas Korbar <tkorbar@redhat.com> - 4.9.2-18
- Improve fix for RHEL-91005
- Resolves: RHEL-91005