简体   繁体   中英

C# Update cipher Renci.SshNet

We are using Renci.SshNet C# library to connect to SFTP server.

Today connection on code line

client.Connect();

to server stopped working with error message:

Unhandled Exception: Renci.SshNet.Common.SshConnectionException: The connection was closed by the server: Your cipher needs to be updated: https://developer.eba y.com/devzone/merchant-products/mipng/user-guide-en/default.html#advanced-featur es.html. please contact MIP Support for help (ByApplication). at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)

I installed latest SSH.NET and .NET Framework, and still same error

Could anyone help what needs to be done to fix that error?

Appreciate any help

I encountered the same issue. Here is the fix for SSH.NET client w/ C#

var connectionInfo = new ConnectionInfo(...);

var deprecatedMacs = new List<string>
  {
    "hmac-md5",
    "hmac-md5-96",
    "hmac-md5-etm@openssh.com",
    "hmac-sha1-96",
    "hmac-sha2-256-96",
    "hmac-sha2-512-96"
  };

  var deprecatedCiphers = new List<string>
  {
    "aes128-cbc",
    "aes192-cbc",
    "aes256-cbc",
    "blowfish-cbc",
    "3des-cbc",
    "3des-ctr",
    "arcfour",
    "arcfour128",
    "arcfour256"
  };

  // remove deprecated macs
  foreach(var deprecatedMac in deprecatedMacs)
  {
    connectionInfo.HmacAlgorithms.Remove(deprecatedMac);
  }

  // remove deprecated ciphers
  foreach(var deprecatedCipher in deprecatedCiphers)
  {
    connectionInfo.Encryptions.Remove(deprecatedCipher);
  }

  using (var client = new SftpClient(connectionInfo))
  {
    try
    {
      
      client.Connect(); // Should work now

    }

    catch (Exception ex)
    {
        // ...
    }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM