sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
MIT License
3.87k stars 915 forks source link

Update from 2020.0.2 to 2024.0.0, could not load System.Security.Cryptography.ECCurve #1396

Closed HAVASxMARCOUxOLIVIER closed 1 month ago

HAVASxMARCOUxOLIVIER commented 1 month ago

Hi,

I have to update SSH.NET from version 2020.0.2 to the last version and when I test the connections with serveral SFTP servers, I have the same issue for 2 of them on client.connect().

On 2020.0.2 HostKeyAlgorithm = ecdsa-sha2-nistp256, ServerEncryption = aes256-ctr, ServerHmacAlgorithm = hmac-sha2-256

On 2024.0.0 Exception in Impossible de charger le type 'System.Security.Cryptography.ECCurve' à partir de l'assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

My exe is currently on Framework 4.6.1. If I update to 4.6.2 or 4.8 and I have the same issue.

Regards

Rob-Hague commented 1 month ago

Your application appears to be loading the .NET Standard 2.0 version of the library. That's probably expected when your application targets .NET Framework 4.6.1 but is unexpected if your application targets .NET Framework 4.6.2 because the library has an explicit target for that. How is the library being referenced?

This would probably stop that specific error but it's not a great workaround and there could be other problems:

connectionInfo.HostKeyAlgorithms.Remove("ecdsa-sha2-nistp256");
connectionInfo.HostKeyAlgorithms.Remove("ecdsa-sha2-nistp384");
connectionInfo.HostKeyAlgorithms.Remove("ecdsa-sha2-nistp521");
HAVASxMARCOUxOLIVIER commented 1 month ago

Hi,

SSH.NET version 2024.0.0 works now on my solution on .Net Framework 4.6.2. I had to uninstall and install the package nuget SSH.NET after the upgrade from .Net Framework 4.6.1 to 4.6.2. On Framework 4.6.1, removing the HostKeyAlgorithm does not solve the issue.

It seems the upgrade to .Net Framework 4.6.2 (or highter) is the solution.

Thank for your help. Regards