From 0876e88330abfb7752d5e4c3164cba266e2a66b7 Mon Sep 17 00:00:00 2001 From: staecthSICKAG <145429787+staecthSICKAG@users.noreply.github.com> Date: Wed, 6 Mar 2024 06:42:01 +0100 Subject: [PATCH] Changed Private Key Regex to be more tolerant regarding new lines at end of key file (#1344) --- src/Renci.SshNet/PrivateKeyFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renci.SshNet/PrivateKeyFile.cs b/src/Renci.SshNet/PrivateKeyFile.cs index d4259458..68408536 100644 --- a/src/Renci.SshNet/PrivateKeyFile.cs +++ b/src/Renci.SshNet/PrivateKeyFile.cs @@ -64,7 +64,7 @@ namespace Renci.SshNet /// public class PrivateKeyFile : IPrivateKeySource, IDisposable { - private static readonly Regex PrivateKeyRegex = new Regex(@"^-+ *BEGIN (?\w+( \w+)*) PRIVATE KEY *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?[A-Z0-9-]+),(?[A-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?([a-zA-Z0-9/+=]{1,80}\r?\n)+)-+ *END \k PRIVATE KEY *-+", + private static readonly Regex PrivateKeyRegex = new Regex(@"^-+ *BEGIN (?\w+( \w+)*) PRIVATE KEY *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?[A-Z0-9-]+),(?[A-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?([a-zA-Z0-9/+=]{1,80}\r?\n)+)(\r?\n)?-+ *END \k PRIVATE KEY *-+", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture); private readonly List _hostAlgorithms = new List();