Browse Source

Correcting harmless assertion when selecting public key

Source commit: 7839b5714ec3452f65b0c949baed0e940452561b
Martin Prikryl 1 year ago
parent
commit
520d535f27
1 changed files with 12 additions and 9 deletions
  1. 12 9
      source/forms/SiteAdvanced.cpp

+ 12 - 9
source/forms/SiteAdvanced.cpp

@@ -1392,16 +1392,19 @@ void __fastcall TSiteAdvancedDialog::PrivateKeyEdit3AfterDialog(TObject * Sender
       {
         UnicodeString FileName = ExpandEnvironmentVariables(Name);
         TKeyType Type = KeyType(FileName);
-        // This gonna fail for encrypted keys
-        TPrivateKey * PrivateKey = LoadKey(Type, FileName, EmptyStr);
-        try
+        if ((Type == ktSSH2) || (Type == ktOpenSSHPEM) || (Type == ktOpenSSHNew) || (Type == ktSSHCom))
         {
-          UnicodeString CertificateFileName = AddMatchingKeyCertificate(PrivateKey, FileName);
-          DetachedCertificateEdit->Text = CertificateFileName;
-        }
-        __finally
-        {
-          FreeKey(PrivateKey);
+          // This gonna fail for encrypted keys
+          TPrivateKey * PrivateKey = LoadKey(Type, FileName, EmptyStr);
+          try
+          {
+            UnicodeString CertificateFileName = AddMatchingKeyCertificate(PrivateKey, FileName);
+            DetachedCertificateEdit->Text = CertificateFileName;
+          }
+          __finally
+          {
+            FreeKey(PrivateKey);
+          }
         }
       }
       catch (Exception & E)