Skip to content

Commit 0876e88

Browse files
Changed Private Key Regex to be more tolerant regarding new lines at end of key file (#1344)
1 parent e66a032 commit 0876e88

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Renci.SshNet/PrivateKeyFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace Renci.SshNet
6464
/// </remarks>
6565
public class PrivateKeyFile : IPrivateKeySource, IDisposable
6666
{
67-
private static readonly Regex PrivateKeyRegex = new Regex(@"^-+ *BEGIN (?<keyName>\w+( \w+)*) PRIVATE KEY *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[A-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?<data>([a-zA-Z0-9/+=]{1,80}\r?\n)+)-+ *END \k<keyName> PRIVATE KEY *-+",
67+
private static readonly Regex PrivateKeyRegex = new Regex(@"^-+ *BEGIN (?<keyName>\w+( \w+)*) PRIVATE KEY *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[A-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?<data>([a-zA-Z0-9/+=]{1,80}\r?\n)+)(\r?\n)?-+ *END \k<keyName> PRIVATE KEY *-+",
6868
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture);
6969

7070
private readonly List<HostAlgorithm> _hostAlgorithms = new List<HostAlgorithm>();

0 commit comments

Comments
 (0)