Class MtlsHandlerOwner

Namespace
Kuestenlogik.Bowire.Auth
Assembly
Kuestenlogik.Bowire.dll

Bundles a pre-configured HttpMessageHandler with the X509 resources whose lifetime must match it. Disposing the owner disposes the handler and every cert it holds — caller places this in the finally next to the per-call HttpClient / GrpcChannel.

One owner type rather than one per protocol: REST uses HttpClientHandler (its ClientCertificates collection is the natural shape); gRPC uses SocketsHttpHandler (its SslOptions property carries the same data via SslClientAuthenticationOptions). Both inherit from HttpMessageHandler, so callers can hold the abstract base type without caring which factory built it.

public sealed class MtlsHandlerOwner : IDisposable
Inheritance
MtlsHandlerOwner
Implements
Inherited Members

Properties

Handler

public HttpMessageHandler Handler { get; }

Property Value

HttpMessageHandler

Methods

CreateHttpClientHandler(MtlsConfig, out string?)

Build an HttpClientHandler wired up with this config — natural fit for REST plugins routing through HttpClient. Returns null on PEM-parse failure with a human-readable error.

public static MtlsHandlerOwner? CreateHttpClientHandler(MtlsConfig config, out string? error)

Parameters

config MtlsConfig
error string

Returns

MtlsHandlerOwner

CreateSocketsHttpHandler(MtlsConfig, out string?)

Build a SocketsHttpHandler wired up with this config — natural fit for gRPC plugins routing through HttpMessageHandler on top of HTTP/2. The cert lands on SslOptions.ClientCertificates; the same TLS handshake mechanics as REST, just expressed via the SocketsHttpHandler API.

public static MtlsHandlerOwner? CreateSocketsHttpHandler(MtlsConfig config, out string? error)

Parameters

config MtlsConfig
error string

Returns

MtlsHandlerOwner

Dispose()

public void Dispose()