mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Fix inline PEM normalization placement
This commit is contained in:
committed by
GitHub
parent
50eef06cf5
commit
9886329c41
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user