Pārlūkot izejas kodu

Logging a complete host key only on Debug log level

Source commit: 11a479cbccfe8dc493b0230c1e318e433af03b16
Martin Prikryl 7 gadi atpakaļ
vecāks
revīzija
4060c7b495
1 mainītis faili ar 13 papildinājumiem un 3 dzēšanām
  1. 13 3
      source/core/SecureShell.cpp

+ 13 - 3
source/core/SecureShell.cpp

@@ -2215,7 +2215,10 @@ void __fastcall TPasteKeyHandler::Paste(TObject * /*Sender*/, unsigned int & Ans
 void __fastcall TSecureShell::VerifyHostKey(UnicodeString Host, int Port,
   const UnicodeString KeyType, UnicodeString KeyStr, UnicodeString Fingerprint)
 {
-  LogEvent(FORMAT(L"Verifying host key %s %s with fingerprint %s", (KeyType, FormatKeyStr(KeyStr), Fingerprint)));
+  if (Configuration->ActualLogProtocol >= 1)
+  {
+    LogEvent(FORMAT(L"Verifying host key %s %s with fingerprints %s", (KeyType, FormatKeyStr(KeyStr), Fingerprint)));
+  }
 
   GotHostKey();
 
@@ -2257,8 +2260,15 @@ void __fastcall TSecureShell::VerifyHostKey(UnicodeString Host, int Port,
     }
     else
     {
-      UnicodeString FormattedKey = Fingerprint ? StoredKey : FormatKeyStr(StoredKey);
-      LogEvent(FORMAT(L"Host key does not match cached key %s", (FormattedKey)));
+      if (Configuration->ActualLogProtocol >= 1)
+      {
+        UnicodeString FormattedKey = Fingerprint ? StoredKey : FormatKeyStr(StoredKey);
+        LogEvent(FORMAT(L"Host key does not match cached key %s", (FormattedKey)));
+      }
+      else
+      {
+        LogEvent(L"Host key does not match cached key");
+      }
     }
   }