Explorar o código

Changed Private Key Regex to be more tolerant regarding new lines at end of key file (#1344)

staecthSICKAG hai 1 ano
pai
achega
0876e88330
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/Renci.SshNet/PrivateKeyFile.cs

+ 1 - 1
src/Renci.SshNet/PrivateKeyFile.cs

@@ -64,7 +64,7 @@ namespace Renci.SshNet
     /// </remarks>
     public class PrivateKeyFile : IPrivateKeySource, IDisposable
     {
-        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 *-+",
+        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 *-+",
                                                                   RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture);
 
         private readonly List<HostAlgorithm> _hostAlgorithms = new List<HostAlgorithm>();