Skip to content

fix https://github.com/sshnet/SSH.NET/issues/407 + fixed whitespaces #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Renci.SshNet/ConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ public class ConnectionInfo : IConnectionInfoInternal
/// </value>
public int MaxSessions { get; set; }

/// <summary>
/// send client keys right after server version exchange, don't wait for server
/// </summary>
public bool EarlyClientInitMessage { get; set; }

/// <summary>
/// Occurs when authentication banner is sent by the server.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/Renci.SshNet/Security/KeyExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ public virtual void Start(Session session, KeyExchangeInitMessage message)
{
Session = session;

SendMessage(session.ClientInitMessage);
if (!Session.ConnectionInfo.EarlyClientInitMessage)
{
SendMessage(session.ClientInitMessage);
}
else
{
DiagnosticAbstraction.Log("KeyExchange: ClientInitMessage already sent, skip");
}

// Determine encryption algorithm
var clientEncryptionAlgorithmName = (from b in session.ConnectionInfo.Encryptions.Keys
Expand Down
6 changes: 6 additions & 0 deletions src/Renci.SshNet/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ public void Connect()
// mark the message listener threads as started
_messageListenerCompleted.Reset();

if (ConnectionInfo.EarlyClientInitMessage)
{
DiagnosticAbstraction.Log("Sending early client init message");
SendMessage(ClientInitMessage);
}

// Start incoming request listener
ThreadAbstraction.ExecuteThread(MessageListener);

Expand Down