Class BowireHttpClientFactory
- Namespace
- Kuestenlogik.Bowire.Net
- Assembly
- Kuestenlogik.Bowire.dll
Builds an HttpClient whose certificate validation callback consults LocalhostCertTrust on every request. Lets HttpClient- based protocol plugins (REST, GraphQL, SSE, MCP, OData) opt into the same loopback-cert relaxation that SignalR / WebSocket already use, without each plugin re-implementing the validation-callback dance.
Defence in depth — the relaxed callback only returns true when both
(a) the OS trust check failed *and* (b) IsTrustedFor(IConfiguration?, string, string)
returns true for the request URL. A misconfigured production host where
`Bowire:TrustLocalhostCert=true` was set against a non-loopback URL still
validates strictly.
public static class BowireHttpClientFactory
- Inheritance
-
BowireHttpClientFactory
- Inherited Members
Methods
Create(IConfiguration?, string, TimeSpan?)
Creates a long-lived HttpClient suitable for a plugin's
instance field. The validation callback closes over config
and pluginId so per-plugin overrides
(Bowire:{pluginId}:TrustLocalhostCert) keep working.
public static HttpClient Create(IConfiguration? config, string pluginId, TimeSpan? timeout = null)
Parameters
configIConfigurationApplication IConfiguration; usually obtained via
serviceProvider.GetService<IConfiguration>()inIBowireProtocol.Initialize. Passnullto disable the relaxed callback entirely (standalone test paths).pluginIdstringThe plugin id (e.g.
"rest","graphql").timeoutTimeSpan?Optional client timeout. Default:
HttpClientdefault (100 s).
Returns
CreateHandler(IConfiguration?, string)
Same as Create(IConfiguration?, string, TimeSpan?) but exposes the underlying HttpClientHandler — useful for plugins that need to layer additional configuration on top (cookies, proxies, redirect policy) before wrapping it in an HttpClient.
public static HttpClientHandler CreateHandler(IConfiguration? config, string pluginId)
Parameters
configIConfigurationpluginIdstring
Returns
CreateSocketsHttpHandler(IConfiguration?, string, string?)
Builds a SocketsHttpHandler with the same loopback-cert opt-in as CreateHandler(IConfiguration?, string), but configured for protocols that need HTTP/2 directly (gRPC's HttpClient- less channel). The validation callback consults LocalhostCertTrust per request, so per-plugin overrides keep working the same way as on the regular HttpClient path.
public static SocketsHttpHandler CreateSocketsHttpHandler(IConfiguration? config, string pluginId, string? serverUrl = null)
Parameters
configIConfigurationApplication IConfiguration; null disables relaxed validation.
pluginIdstringPlugin id used for
Bowire:{pluginId}:TrustLocalhostCertoverrides.serverUrlstringOptional target URL used to gate the validation callback. The plugin gives us the URL eagerly (rather than reading
request.RequestUriinside the callback) because gRPC's RemoteCertificateValidationCallback is the SslStream-level one — it doesn't carry an HttpRequestMessage, so we close over the URL here instead.