Using SshClient on Linux under Wine throws System.Security.Cryptography.CryptographicException
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- csharp
- 领域
- cryptography
调研方向
从 KeyExchangeECCurve25519 开始,检查 SshClient 如何公开 ConnectionInfo.KeyExchangeAlgorithms。查看 issue 中展示的 BclImpl 和 BouncyCastleImpl 选择,然后确定调用方如何在连接前配置实现。完成的标准是:无需手动移除密钥交换算法,即可为 Wine 选择已配置的 BouncyCastle 路径。
由索引模型根据 Issue 内容生成。
描述
SSH.NET Version: 2026.0.0
.NET Version: 10.0.11
Wine Version: 11.0
When trying to connect a SshClient from a Windows Application running under Wine, I get the following exception:
System.PlatformNotSupportedException: The specified curve 'Curve25519' or its parameters are not valid for this platform.
---> System.Security.Cryptography.CryptographicException: Unknown error (0x80090029)
at System.Security.Cryptography.CngKey.Create(CngAlgorithm algorithm, String keyName, CngKeyCreationParameters creationParameters)
at System.Security.Cryptography.CngAlgorithmCore.GetOrGenerateKey(Nullable`1 curve)
--- End of inner exception stack trace ---
at System.Security.Cryptography.CngAlgorithmCore.GetOrGenerateKey(Nullable`1 curve)
at System.Security.Cryptography.ECDiffieHellmanCng.GenerateKey(ECCurve curve)
at Renci.SshNet.Security.KeyExchangeECCurve25519.BclImpl.GenerateClientPublicKey()
at Renci.SshNet.Security.KeyExchangeECCurve25519.StartImpl()
at Renci.SshNet.Security.KeyExchangeECCurve25519.Start(Session session, KeyExchangeInitMessage message, Boolean sendClientInitMessage)
at Renci.SshNet.Session.OnKeyExchangeInitReceived(KeyExchangeInitMessage message)
at Renci.SshNet.Messages.Transport.KeyExchangeInitMessage.Process(Session session)
at Renci.SshNet.Session.MessageListener()
--- End of stack trace from previous location ---
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
at <my code>
Code executed:
var sshClient = new Renci.SshNet.SshClient(hostname, port, username, password);
sshClient.Connect();
I understand this is a Wine specific issue, because the bcrypt.dll / ncrypt.dll are heavily stubbed under Wine and Windows CNG (ECDH kex algorithms) is not fully supported as of right now. So not really a SSH.NET bug.
I was able to circumvent the issue by removing ECDH key exchange algorithms before connecting via my SshClient:
foreach (var algo in sshClient.ConnectionInfo.KeyExchangeAlgorithms.Keys.ToList())
{
if (!algo.StartsWith("diffie-hellman-group", StringComparison.Ordinal))
sshClient.ConnectionInfo.KeyExchangeAlgorithms.Remove(algo);
}
Obviously this is not really a good solution.
As a suggestion, it would be nice to have an option to switch to the BouncyCastle implementations via e.g. some config option.
For example in KeyExchangeECCurve25519:
public override void Start(Session session, KeyExchangeInitMessage message, bool sendClientInitMessage)
{
base.Start(session, message, sendClientInitMessage);
#if NET
if (!_forceBouncyCastleImpl && System.OperatingSystem.IsWindowsVersionAtLeast(10))
{
_impl = new BclImpl();
}
else
#endif
{
_impl = new BouncyCastleImpl();
}
StartImpl();
}
where _forceBouncyCastleImpl is just some placeholder to force using the BouncyCastle implementation that can be somehow configured.
(As a side note: This issues did not occur with older SSH.NET versions or on .NET Framework)
- 主要语言
- C#
- 星标
- 4.4k
- 派生
- 993
- 平均合并
- 9 天 21 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sshnet/SSH.NET 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 67/100
-
难度 4/5 3-5 天 新手友好度 55/100
相似的 Issue
-
bug documentation frontend
难度 2/5 1-3 小时 新手友好度 72/100
azurenoops/spin_agent#975 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
难度 2/5 1-3 小时 新手友好度 92/100
dotnet/AspNetCore.Docs#37699 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
SubtitleEdit/subtitleedit#15108 · 1 条评论 ·
-
area/docs-content Bug pulumi/docs
难度 1/5 1-3 小时 新手友好度 94/100