Class BowireNetworkPolicy

Namespace
Kuestenlogik.Bowire.Net
Assembly
Kuestenlogik.Bowire.dll

How Bowire's outbound connections leave the machine (#680): through which proxy, past which hosts directly, and trusting which extra certificate authorities.

public static class BowireNetworkPolicy
Inheritance
BowireNetworkPolicy
Inherited Members

Remarks

Settings come in layers, later ones winning field by field: the built-in default (system), the global file, the active workspace's override, and the host configuration (Bowire:Network:* from appsettings, BOWIRE_Bowire__Network__* or the --proxy-url / --no-proxy / --ca-bundle flags). The host configuration wins because it is the operator's: a CI job that passes --proxy-url means it.

Proxy is one IWebProxy that re-resolves on every request. A plugin builds its HttpClient once, at startup; the workspace is only known per call. Asking the proxy object per request is what lets one long-lived client follow whichever workspace the call came from. The workspace is the one BowirePluginSettingsScope names, which every Bowire endpoint enters from its workspaceId parameter.

Loopback targets always go direct. A local dev server behind the corporate proxy is never what anyone means, and the proxy could not reach it anyway.

Properties

Current

The settings in force for the current call's workspace.

public static BowireEffectiveNetwork Current { get; }

Property Value

BowireEffectiveNetwork

Proxy

The proxy every Bowire-built handler uses; resolves per request.

public static IWebProxy Proxy { get; }

Property Value

IWebProxy

Methods

Apply(HttpClientHandler)

Route handler through the policy: the per-request proxy, and the CA bundle on top of whatever validation it already has. Call it after the handler's own certificate callback is set.

public static HttpClientHandler Apply(HttpClientHandler handler)

Parameters

handler HttpClientHandler

Returns

HttpClientHandler

Apply(SocketsHttpHandler)

Route handler through the policy: the per-request proxy, and the CA bundle on top of whatever validation it already has. Call it after the handler's own certificate callback is set.

public static SocketsHttpHandler Apply(SocketsHttpHandler handler)

Parameters

handler SocketsHttpHandler

Returns

SocketsHttpHandler

Apply(ClientWebSocketOptions)

Route handler through the policy: the per-request proxy, and the CA bundle on top of whatever validation it already has. Call it after the handler's own certificate callback is set.

public static ClientWebSocketOptions Apply(ClientWebSocketOptions options)

Parameters

options ClientWebSocketOptions

Returns

ClientWebSocketOptions

For(string?)

The settings in force for workspaceId (null: global only).

public static BowireEffectiveNetwork For(string? workspaceId)

Parameters

workspaceId string

Returns

BowireEffectiveNetwork

InstallAsProcessDefault()

Make Proxy the process-wide DefaultProxy, so connections Bowire does not build itself — plugin downloads, the update check, catalogue providers, third-party client libraries — follow the same settings.

public static void InstallAsProcessDefault()

Remarks

Only the standalone tool calls this. Embedded in someone else's ASP.NET app, Bowire must not change how the host's own HttpClients connect, so there the policy reaches only the handlers Bowire builds.

Invalidate()

Forget cached resolutions; called when a settings layer changes.

public static void Invalidate()

Layers(string?)

The layers for workspaceId, for the settings UI.

public static (BowireNetworkSettings? Global, BowireNetworkSettings? Workspace, BowireNetworkSettings Host) Layers(string? workspaceId)

Parameters

workspaceId string

Returns

(BowireNetworkSettings Global, BowireNetworkSettings Workspace, BowireNetworkSettings Host)

TrustsCustomCa(X509Certificate?, X509Chain?, SslPolicyErrors)

Whether the configured CA bundle vouches for a certificate the system store rejected. Only a chain problem can be rescued; a wrong host name or a missing certificate stays a failure whatever the bundle says.

public static bool TrustsCustomCa(X509Certificate? certificate, X509Chain? chain, SslPolicyErrors errors)

Parameters

certificate X509Certificate
chain X509Chain
errors SslPolicyErrors

Returns

bool

UseConfiguration(IConfiguration?)

Hand the policy the host configuration. The workbench does this when it maps its endpoints, the CLI at startup. Without it only the files apply.

public static void UseConfiguration(IConfiguration? configuration)

Parameters

configuration IConfiguration

UseKeyring(Func<string, string?>?)

How keyring:service/account password references resolve. Set by the keyring module when it is loaded; without it only env: works.

public static void UseKeyring(Func<string, string?>? lookup)

Parameters

lookup Func<string, string>