-
-
Notifications
You must be signed in to change notification settings - Fork 967
Closed
Description
The documentation says "BEGIN ENCRYPTED PRIVATE KEY" is supported private key format. But when I use the following key the exception "Key 'ENCRYPTED' is not supported." is thrown.
-----BEGIN ENCRYPTED PRIVATE KEY-----
XYZ...
-----END ENCRYPTED PRIVATE KEY-----
When looking at the source code of "PrivateKeyFile.cs" it also looks like this simply is not supported:
private void Open(Stream privateKey, string passPhrase)
{
if (privateKey is null)
{
throw new ArgumentNullException(nameof(privateKey));
}
Match privateKeyMatch;
using (var sr = new StreamReader(privateKey))
{
var text = sr.ReadToEnd();
privateKeyMatch = PrivateKeyRegex.Match(text);
}
if (!privateKeyMatch.Success)
{
throw new SshException("Invalid private key file.");
}
var keyName = privateKeyMatch.Result("${keyName}");
var cipherName = privateKeyMatch.Result("${cipherName}");
var salt = privateKeyMatch.Result("${salt}");
var data = privateKeyMatch.Result("${data}");
...
switch (keyName)
{
case "RSA":
...
break;
case "DSA":
...
break;
case "EC":
..
break;
case "OPENSSH":
...
break;
case "SSH2 ENCRYPTED":
...
break;
default:
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Key '{0}' is not supported.", keyName));
}
}
First of all the variable keyName will contain "ENCRYPTED" and there is no case for that in the switch statement. So it wil throw the mentioned exception. Also if it was going to match with "RSA" the passPhrase would not be used?
So either the regex is wrong and extracts the wrong values or the implementation is simply missing and not true according to the documentation.
I'm using the version "2024.1.0" btw.
Metadata
Metadata
Assignees
Labels
No labels