From 30ee11e239d9f357d0b1c9200cc310fc2edb2566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thore=20St=C3=A4cker?= Date: Tue, 5 Mar 2024 09:46:58 +0100 Subject: [PATCH] Changed Private Key Regex to be more tolerant regarding new lines at end of key file --- 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 d42594583..68408536a 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();