Table of Contents

Method CreateHttpConnectCallback

Namespace
SshSharp
Assembly
SshSharp.dll

CreateHttpConnectCallback()

A ConnectCallback that makes HttpClient's connections through this SSH connection (OpenTcpTunnelAsync(string, int, CancellationToken)), so it can reach web services only the server reaches, such as an internal API behind a bastion. Host names are resolved by the server. TLS still runs end to end, from here to the service. Set UseProxy to false: with a system proxy configured, HttpClient would otherwise connect to that proxy, through the server, instead of to the service.

public Func<SocketsHttpConnectionContext, CancellationToken, ValueTask<Stream>> CreateHttpConnectCallback()

Returns

Func<SocketsHttpConnectionContext, CancellationToken, ValueTask<Stream>>

Examples

using var http = new HttpClient(new SocketsHttpHandler { ConnectCallback = client.CreateHttpConnectCallback(), UseProxy = false });
var status = await http.GetStringAsync("https://internal-api.corp/health");