mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-10-25 10:39:55 +08:00
Handle lower-case hex in private key's salt field (#179)
* Handle lower-case hex in private key's salt field I'm using BouncyCastle (http://bouncycastle.org/) to produce public/private key pairs. In later versions of SSH.NET an exception is thrown (SshException: "Invalid private key file.") while establishing connection using the private keys previously generated. It seems to be an issue with the regex matching the private key file data which this commit handles properly. * add test --------- Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
This commit is contained in:
co-authored by
Robert Hague
parent
239fe31123
commit
bdaa16463a
@@ -119,7 +119,7 @@ namespace Renci.SshNet
|
||||
/// </remarks>
|
||||
public partial class PrivateKeyFile : IPrivateKeySource, IDisposable
|
||||
{
|
||||
private const string PrivateKeyPattern = @"^-+ *BEGIN (?<keyName>\w+( \w+)*) *-+\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 const string PrivateKeyPattern = @"^-+ *BEGIN (?<keyName>\w+( \w+)*) *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[a-fA-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 const string CertificatePattern = @"(?<type>[-\w]+@openssh\.com)\s(?<data>[a-zA-Z0-9\/+=]*)(\s+(?<comment>.*))?";
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
|
||||
Reference in New Issue
Block a user