Browse Source

Issue 2335 – Tunneled session password is not remembered

https://winscp.net/tracker/2335
(cherry picked from commit ff0a744b58cc7e248ecb7708880153d68b9e67d6)

Source commit: 9131b259c2e14f8de479c42a5a92b63d2a6a0bc1
Martin Prikryl 11 months ago
parent
commit
4cbc820661
2 changed files with 5 additions and 2 deletions
  1. 4 2
      source/core/Terminal.cpp
  2. 1 0
      source/core/Terminal.h

+ 4 - 2
source/core/Terminal.cpp

@@ -1208,6 +1208,8 @@ __fastcall TTerminal::TTerminal(TSessionData * SessionData, TConfiguration * Con
   FConfiguration = Configuration;
   FSessionData = new TSessionData(L"");
   FSessionData->Assign(SessionData);
+  // Cache it, in case it changes (particularly by ConfigureTunnel)
+  FPasswordEncryptionKey = SessionData->GetSessionPasswordEncryptionKey();
   TDateTime Started = Now(); // use the same time for session and XML log
   FLog = new TSessionLog(this, Started, FSessionData, Configuration);
   if (ActionLog != NULL)
@@ -1345,7 +1347,7 @@ void __fastcall TTerminal::Idle()
 //---------------------------------------------------------------------
 RawByteString __fastcall TTerminal::EncryptPassword(const UnicodeString & Password)
 {
-  return Configuration->EncryptPassword(Password, SessionData->GetSessionPasswordEncryptionKey());
+  return Configuration->EncryptPassword(Password, FPasswordEncryptionKey);
 }
 //---------------------------------------------------------------------
 UnicodeString __fastcall TTerminal::DecryptPassword(const RawByteString & Password)
@@ -1353,7 +1355,7 @@ UnicodeString __fastcall TTerminal::DecryptPassword(const RawByteString & Passwo
   UnicodeString Result;
   try
   {
-    Result = Configuration->DecryptPassword(Password, SessionData->GetSessionPasswordEncryptionKey());
+    Result = Configuration->DecryptPassword(Password, FPasswordEncryptionKey);
   }
   catch(EAbort &)
   {

+ 1 - 0
source/core/Terminal.h

@@ -161,6 +161,7 @@ friend class TParallelOperation;
 
 private:
   TSessionData * FSessionData;
+  UnicodeString FPasswordEncryptionKey;
   TSessionLog * FLog;
   TActionLog * FActionLog;
   bool FActionLogOwned;