sshnet / sshnet/SSH.NET

CryptographicException in BaseClient.Connect()

Open
#805 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Using SSH.NET 2020.0.1, occasionally CryptographicException is thrown in call to BaseClient.Connect():

System.Security.Cryptography.CryptographicException: Hash not valid for use in specified state.
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils.HashData(SafeHashHandle hHash, Byte[] data, Int32 cbData, Int32 ibStart, Int32 cbSize)
   at System.Security.Cryptography.SHA1CryptoServiceProvider.HashCore(Byte[] rgb, Int32 ibStart, Int32 cbSize)
   at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer)
   at Renci.SshNet.Security.Cryptography.CipherDigitalSignature.Sign(Byte[] input)
   at Renci.SshNet.Security.KeyHostAlgorithm.Sign(Byte[] data)
   at Renci.SshNet.PrivateKeyAuthenticationMethod.Authenticate(Session session)
   at Renci.SshNet.ClientAuthentication.TryAuthenticate(ISession session, AuthenticationState authenticationState, String[] allowedAuthenticationMethods, SshAuthenticationException& authenticationException)
   at Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
   at Renci.SshNet.ConnectionInfo.Authenticate(ISession session, IServiceFactory serviceFactory)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.CreateAndConnectSession()
   at Renci.SshNet.BaseClient.Connect()

Will try to gather more info and report back.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at BaseClient.Connect() and follow the reported stack through PrivateKeyAuthenticationMethod.Authenticate, KeyHostAlgorithm.Sign, and CipherDigitalSignature.Sign. Reproduce the intermittent CryptographicException using SSH.NET 2020.0.1 and inspect the surrounding authentication and signing flow; done means the cause is identified and the connection no longer produces this exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.