Using SshClient on Linux under Wine throws System.Security.Cryptography.CryptographicException
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- csharp
- Lĩnh vực
- cryptography
Hướng nghiên cứu
Bắt đầu từ KeyExchangeECCurve25519 và kiểm tra cách SshClient cung cấp ConnectionInfo.KeyExchangeAlgorithms. Xem xét lựa chọn BclImpl và BouncyCastleImpl được nêu trong issue, sau đó xác định cách bên gọi có thể cấu hình implementation trước khi kết nối. Hoàn thành có nghĩa là có thể chọn đường dẫn BouncyCastle đã cấu hình cho Wine mà không cần xóa thủ công các thuật toán trao đổi khóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- C#
- Star
- 4.4k
- Fork
- 990
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sshnet/SSH.NET
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
-
ShellStream.Expect over-discards on undecodable bytes, driving ArrayBuffer.ActiveLength negativeĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
Tất cả issue của sshnet/SSH.NET
Issue tương tự
-
test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NethermindEth/nethermind#14274 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
area:frontend bug FE P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
klasolsson81/jobbliggaren#2023 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
shimat/opencvsharp#2154 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
subsystem: UI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Open-Systems-Pharmacology/PK-Sim#3812 ·
Maintainer thường phản hồi trong vòng 1 ngày