Archived Forum Post

Index of archived forum posts

Question:

SSHTunnel Security and Instance Disposing

Oct 24 '12 at 11:24

Hi, i have a multi treading C# software that call SSH Tunnel within one of the instances, how can i verify that other parties could not read the ssh credentials that i have provided to the chilkat component ? maybe call a function that prevents credential read.

also, i need to close and release the component instance a few times a day, calling Dispose() is enough or sshTunnel = null is required ?


Answer

The Dispose call will close/tear down any tunnels that might be open. The only thing you're left with is the object instance itself taking up a little memory. Given that it's just one line of code, I would set sshTunnel = null after calling Dispose. No reason not to..

I don't fully understand what you mean by "other parties reading the SSH credentials". SSH authentication happens after the secure channel (tunnel) becomes established, so the login/password is not transmitted over an insecure connection.


Answer

i have received the following errors while trying to start the connection again with the component,

ChilkatLog:
  BeginAccepting:
    DllDate: Aug  5 2012
    UnlockPrefix: LIMPOXSSH
    Username: ENDPOINT_5-PC:EndPoint_1
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    listenPort: 48492
    destPort: 80
    destHostname: 192.168.1.208
    acceptThreadSessionLogPath: 
    Listen thread did not start.
    Failed.
  --BeginAccepting
--ChilkatLog
after i have receive this error i do those action and try again:
sshTunnel.Dispose();
sshTunnel = null;
sshTunnel = new SshTunnel();

is there a better way to handle those errors ?


Answer

after some testing, i have better remarks,

after:

sshTunnel.Dispose();
sshTunnel = null;
sshTunnel = new SshTunnel();

i have lost the instance, and the background thread is still listening, using Dispose() did not closed the current listening background thread.

so now i am using

sshTunnel.StopAccepting();
sshTunnel.StopAllTunnels(1);

on normal usage and only dispose and null after those 2 commands. this is look like a bug in the Dispose() function.