Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
leefine02 authored and leefine02 committed Jun 18, 2024
1 parent 95d4922 commit 6b28cf3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions RemoteFile/RemoteHandlers/SSHHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal SSHHandler(string server, string serverLogin, string serverPassword, bo

try
{
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(FormatRSAPrivateKey(serverPassword))))
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(FormatPrivateKey(serverPassword))))
{
privateKeyFile = new PrivateKeyFile(ms);
}
Expand Down Expand Up @@ -400,12 +400,14 @@ private void SplitStorePathFile(string pathFileName, out string path, out string
_logger.MethodEntry(LogLevel.Debug);
}

private string FormatRSAPrivateKey(string privateKey)
private string FormatPrivateKey(string privateKey)
{
_logger.MethodEntry(LogLevel.Debug);
_logger.MethodExit(LogLevel.Debug);

String keyType = privateKey.Contains("OPENSSH PRIVATE KEY") ? "OPENSSH" : "RSA";

return privateKey.Replace(" RSA PRIVATE ", "^^^").Replace(" ", System.Environment.NewLine).Replace("^^^", " RSA PRIVATE ") + System.Environment.NewLine;
return privateKey.Replace($" {keyType} PRIVATE ", "^^^").Replace(" ", System.Environment.NewLine).Replace("^^^", $" {keyType} PRIVATE ") + System.Environment.NewLine;
}

private string ConvertToPKCS1(string privateKey)
Expand Down

0 comments on commit 6b28cf3

Please sign in to comment.