1
0
Эх сурвалжийг харах

Bug 2220: Recognizing CertificateFile directive when importing sites from OpenSSH

https://winscp.net/tracker/2220

Source commit: cdb4f32e0a5162f545390d0a72aa3239c6279ef4
Martin Prikryl 2 жил өмнө
parent
commit
ea7204c517
1 өөрчлөгдсөн 20 нэмэгдсэн , 11 устгасан
  1. 20 11
      source/core/SessionData.cpp

+ 20 - 11
source/core/SessionData.cpp

@@ -1613,6 +1613,21 @@ UnicodeString CutOpensshToken(UnicodeString & S)
   return Result;
 }
 //---------------------------------------------------------------------
+static UnicodeString ConvertPathFromOpenssh(const UnicodeString & Path)
+{
+  // It's likely there would be forward slashes in OpenSSH config file and our load/save dialogs
+  // (e.g. when converting keys) work suboptimally when working with forward slashes.
+  UnicodeString Result = GetNormalizedPath(Path);
+  const UnicodeString HomePathPrefix = L"~";
+  if (StartsStr(HomePathPrefix, Result + L"\\"))
+  {
+    Result =
+      GetShellFolderPath(CSIDL_PROFILE) +
+      Result.SubString(HomePathPrefix.Length() + 1, Result.Length() - HomePathPrefix.Length());
+  }
+  return Result;
+}
+//---------------------------------------------------------------------
 void TSessionData::ImportFromOpenssh(TStrings * Lines)
 {
   bool SkippingSection = false;
@@ -1705,17 +1720,11 @@ void TSessionData::ImportFromOpenssh(TStrings * Lines)
           }
           else if (SameText(Directive, L"IdentityFile"))
           {
-            // It's likely there would be forward slashes in OpenSSH config file and our load/save dialogs
-            // (e.g. when converting keys) work suboptimally when working with forward slashes.
-            UnicodeString Path = GetNormalizedPath(Value);
-            const UnicodeString HomePathPrefix = L"~";
-            if (StartsStr(HomePathPrefix, Path + L"\\"))
-            {
-              Path =
-                GetShellFolderPath(CSIDL_PROFILE) +
-                Path.SubString(HomePathPrefix.Length() + 1, Path.Length() - HomePathPrefix.Length());
-            }
-            PublicKeyFile = Path;
+            PublicKeyFile = ConvertPathFromOpenssh(Value);
+          }
+          else if (SameText(Directive, L"CertificateFile"))
+          {
+            DetachedCertificate = ConvertPathFromOpenssh(Value);
           }
           else if (SameText(Directive, L"KbdInteractiveAuthentication"))
           {