Fix inline PEM normalization placement

This commit is contained in:
copilot-swe-agent[bot]
2026-06-23 08:25:11 +00:00
committed by GitHub
parent 50eef06cf5
commit 9886329c41
+21 -21
View File
@@ -309,27 +309,6 @@ namespace Renci.SshNet
}
}
private static string NormalizeInlinePrivateKey(string text)
{
if (text.IndexOfAny(['\r', '\n']) >= 0)
{
return text;
}
var privateKeyMatch = InlinePrivateKeyRegex.Match(text.Trim());
if (!privateKeyMatch.Success)
{
return text;
}
return string.Concat(
privateKeyMatch.Groups["begin"].Value,
"\n",
privateKeyMatch.Groups["data"].Value,
"\n",
privateKeyMatch.Groups["end"].Value);
}
if (!privateKeyMatch.Success)
{
throw new SshException("Invalid private key file.");
@@ -406,6 +385,27 @@ namespace Renci.SshNet
}
}
private static string NormalizeInlinePrivateKey(string text)
{
if (text.IndexOfAny(['\r', '\n']) >= 0)
{
return text;
}
var privateKeyMatch = InlinePrivateKeyRegex.Match(text.Trim());
if (!privateKeyMatch.Success)
{
return text;
}
return string.Concat(
privateKeyMatch.Groups["begin"].Value,
"\n",
privateKeyMatch.Groups["data"].Value,
"\n",
privateKeyMatch.Groups["end"].Value);
}
/// <summary>
/// Opens the specified certificate.
/// </summary>