private void client_HostKeyReceived(object sender, HostKeyEventArgs e) { bool nslookup; DialogResult trust = DialogResult.Yes; e.CanTrust = false; //we clicked yes if the fingerprint matches if (_host.FingerPrint.Length.Equals(0) || !_host.FingerPrint.SequenceEqual(e.FingerPrint)) { if (_host.FingerPrint.Length.Equals(0)) { trust = MessageBox.Show( string.Format("Do you trust the new connection with host {0}[{1}]\r\n\r\nKey fingerprint: {2}\r\n\r\nServer version: {3}", _ci.Host, GetHostAddress(_host.Host, out nslookup), KeyFingerPrint(e), _ci.ServerVersion) , "New host key for " + _host.Host, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); } else { trust = MessageBox.Show( string.Format("Do you trust the changed connection with host {0}[{1}]\r\n\r\nKey fingerprint: {2}\r\n\r\nServer version: {3}", _ci.Host, GetHostAddress(_host.Host, out nslookup), KeyFingerPrint(e), _ci.ServerVersion) , "The host key has changed for " + _host.Host, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); } if (trust == DialogResult.Yes) { _host.FingerPrint = e.FingerPrint; OnHostKeyChange(this, new EventArgs()); } } e.CanTrust = trust.Equals(DialogResult.Yes); }
public void HostKeyEventArgsConstructorTest() { KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value HostKeyEventArgs target = new HostKeyEventArgs(host); Assert.Inconclusive("TODO: Implement code to verify target"); }
private void OnHostKeyReceived(object sender, HostKeyEventArgs e) { string encodedHostKey = Convert.ToBase64String(e.HostKey); hostKeyText.Text = encodedHostKey; e.CanTrust = false; }
private void Session_HostKeyReceived(object sender, HostKeyEventArgs e) { if (this.HostKeyReceived != null) { this.HostKeyReceived(this, e); } }
private void Session_HostKeyReceived(object sender, HostKeyEventArgs e) { var handler = HostKeyReceived; if (handler != null) { handler(this, e); } }
private void SshClient_HostKeyReceived(object sender, HostKeyEventArgs e) { byte[] expectedHostKey = Convert.FromBase64String(settings.ExpectedHostKeyBase64); if (!e.HostKey.SequenceEqual(expectedHostKey)) { e.CanTrust = false; } }
private void ClientOnHostKeyReceived(object sender, HostKeyEventArgs hostKeyEventArgs) { var expectedHostKey = this.IOConnectionProperties.Get(PropertyKeys.HostKey); var fingerprint = BitConverter.ToString(hostKeyEventArgs.FingerPrint); if (expectedHostKey != null && expectedHostKey.Equals(fingerprint, StringComparison.OrdinalIgnoreCase)) { } }
private static bool CanTrustHost(string hostname, HostKeyEventArgs e) { if (_knownHosts.Knows(hostname, e.HostKeyName, e.HostKey, 22)) { return(true); } else { return(false); } }
/// <summary> /// Determines whether the specified host key can be trusted. /// </summary> /// <param name="host">The host algorithm.</param> /// <returns> /// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>. /// </returns> protected bool CanTrustHostKey(KeyHostAlgorithm host) { var args = new HostKeyEventArgs(host); if (this.HostKeyReceived != null) { this.HostKeyReceived(this, args); } return(args.CanTrust); }
internal void VerifyHostKey(object sender, HostKeyEventArgs e, byte[] expectedHostKey) { if (expectedHostKey.SequenceEqual(e.HostKey)) { e.CanTrust = true; } else { e.CanTrust = false; throw new HostKeyMismatchException(); } }
public void CanTrustTest() { KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value HostKeyEventArgs target = new HostKeyEventArgs(host); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.CanTrust = expected; actual = target.CanTrust; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Determines whether the specified host key can be trusted. /// </summary> /// <param name="host">The host algorithm.</param> /// <returns> /// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>. /// </returns> protected bool CanTrustHostKey(KeyHostAlgorithm host) { var handlers = HostKeyReceived; if (handlers != null) { var args = new HostKeyEventArgs(host); handlers(this, args); return(args.CanTrust); } return(true); }
private void CheckHostKey(object sender, HostKeyEventArgs hostKeyEventArgs) { object hostKey = ApplicationStorageHelper.GetHostKey(_applicationStorage, _host); if (hostKey == null) { _applicationStorage.TryAdd(new ApplicationStorage(_host, Convert.ToBase64String(hostKeyEventArgs.HostKey, 0, hostKeyEventArgs.HostKey.Length))); ApplicationStorageHelper.Save(_applicationStorage); } else if (hostKey.ToString() != Convert.ToBase64String(hostKeyEventArgs.HostKey, 0, hostKeyEventArgs.HostKey.Length)) { throw ExceptionHandling.HandleComponentException(System.Reflection.MethodBase.GetCurrentMethod(), new Exception("HostKey does not match previously retrieved HostKey.")); } }
private void HostKeyReceived(object sender, HostKeyEventArgs e) { e.CanTrust = true; }
void M_Client_HostKeyReceived(object sender, HostKeyEventArgs e) { e.CanTrust = e.FingerPrint.SequenceEqual(m_fingerprint) ? true : false; }
private void HostKeyReceivedHandler(object sender, HostKeyEventArgs e) { Debug("Host key received"); e.CanTrust = true; }
private string KeyFingerPrint(HostKeyEventArgs e) { return(e.HostKeyName + " " + e.KeyLength + " " + e.FingerPrint.ToString(':').ToLower()); }