From 9886329c419ade5f4a8a7ba2e1f6736ee552f6b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 08:25:11 +0000 Subject: [PATCH] Fix inline PEM normalization placement --- src/Renci.SshNet/PrivateKeyFile.cs | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Renci.SshNet/PrivateKeyFile.cs b/src/Renci.SshNet/PrivateKeyFile.cs index 2aa1531c..018d68cb 100644 --- a/src/Renci.SshNet/PrivateKeyFile.cs +++ b/src/Renci.SshNet/PrivateKeyFile.cs @@ -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); + } + /// /// Opens the specified certificate. ///