Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: How can i get Host Fingerprint algorith.

$
0
0

I'm using SFTP. I found a very nice event.... "HostKeyReceived". With it I can read the fingerprint. Most common using algorith is SSH-RSA. But what if its a different one?

I found the part of the code that contain the name of the key.

...Renci.SshClient\Renci.SshNet\Common\HostKeyEventArgs.cs

it would be nice, if this code will take into the repository. to know the algorithm name is really nice feature.

 

///<summary>/// Provides data for the HostKeyReceived event.///</summary>publicclass HostKeyEventArgs : EventArgs
    {///<summary>/// Gets or sets a value indicating whether host key can be trusted.///</summary>///<value>///<c>true</c> if host key can be trusted; otherwise, <c>false</c>.///</value>publicbool CanTrust { get; set; }///<summary>/// Gets the host key.///</summary>publicbyte[] HostKey { get; privateset; }///<summary>/// Gets the finger print.///</summary>publicbyte[] FingerPrint { get; privateset; }///<summary>/// Gets the length of the key in bits.///</summary>///<value>/// The length of the key in bits.///</value>publicint KeyLength { get; privateset; }///<summary>/// Algorithm name///</summary>public String Name { get; privateset; } ///new part///<summary>/// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.///</summary>///<param name="host">The host.</param>public HostKeyEventArgs(KeyHostAlgorithm host)
        {this.CanTrust = true;   //  Set default valuethis.HostKey = host.Data;this.Name = host.Name; ///new Partthis.KeyLength = host.Key.KeyLength;using (var md5 = new MD5Hash())
            {this.FingerPrint = md5.ComputeHash(host.Data);
            }
        }
    }


Viewing all articles
Browse latest Browse all 1729

Trending Articles