Selaa lähdekoodia

Bug 2018: TLS session resumption is not working for subsequent FTP transfers with TLS 1.3 when the server requires reuse of the session of the previous transfer

https://winscp.net/tracker/2018
(cherry picked from commit 1f32f2204485b33ca5b9662f677e30e01e3f9e22)

Source commit: 6645eb2a1d788bedf3837a25adc97a214fc16056
Martin Prikryl 4 vuotta sitten
vanhempi
sitoutus
8719ab1bf8
1 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 15 0
      source/filezilla/AsyncSslSocketLayer.cpp

+ 15 - 0
source/filezilla/AsyncSslSocketLayer.cpp

@@ -667,6 +667,21 @@ bool CAsyncSslSocketLayer::HandleSession(SSL_SESSION * Session)
         LogSocketMessageRaw(FZ_LOG_INFO, L"Session ID changed");
       }
       m_sessionid = Session;
+      // Some TLS 1.3 servers require reuse of the session of the previous data connection, not of the main session.
+      // It seems that it's safe to do this even for older TLS versions, but let's not for now.
+      // Once we do, we can simply always use main session's m_sessionid field in the code above.
+      if ((SSL_version(m_ssl) >= TLS1_3_VERSION) && (m_Main != NULL))
+      {
+        if (m_Main->m_sessionid != NULL)
+        {
+          SSL_SESSION_free(m_Main->m_sessionid);
+        }
+        m_Main->m_sessionid = Session;
+        if (Session != NULL)
+        {
+          SSL_SESSION_up_ref(Session);
+        }
+      }
       Result = true;
     }
   }