Client - SetHostKeyHandler, OnHostKey

[C]

__cdecl FlowSshC_Client_SetHostKeyHandler(
  FlowSshC_Client* client,
  FlowSshC_HostKeyHandler handler,
  void* handlerData);

[C++]

[Client] virtual bool OnHostKey(RefPtr<PublicKey> publicKey);

[C#]

[ClientBase] public event HostKeyEventHandler OnHostKey;

[C] Parameters

  • client: FlowSshC_Client pointer.
  • handler: A HostKeyHandler function.
  • handlerData: An application-defined value to be passed to the handler. Optional.

[C++/.NET] Overrides and Events

  • OnHostKey: Informs you about the public-key of the SSH server to which you are trying to connect.
    Parameters:
    • publicKey: A PublicKey object identifying the SSH server.

Handler Return Value

Return false to reject the public-key (host-key) and disconnect. Return true to accept the key.

Remarks

The host-key handler is invoked while establishing a connection with the SSH server, at progress [ConnectStep]SshKeyExchange. It is mandatory that you register/implement this handler. Otherwise, server (host-key) verification fails and the connection is aborted.

In FlowSshNet, an alternative to implementing this handler is to call Client.AcceptHostKeyXxxx methods, which initializes a built-in host key handler by providing information about trusted host keys.