Class MtlsConfig
- Namespace
- Kuestenlogik.Bowire.Auth
- Assembly
- Kuestenlogik.Bowire.dll
Decoded mTLS client-cert configuration carried inline in the request metadata dict via MtlsMarkerKey. Shared between the REST plugin (HttpClientHandler) and the gRPC plugin (SocketsHttpHandler) so every TLS-capable transport speaks the same wire format and only one PEM parser exists in the codebase.
public sealed record MtlsConfig : IEquatable<MtlsConfig>
- Inheritance
-
MtlsConfig
- Implements
- Inherited Members
Constructors
MtlsConfig(string, string, string?, string?, bool)
Decoded mTLS client-cert configuration carried inline in the request metadata dict via MtlsMarkerKey. Shared between the REST plugin (HttpClientHandler) and the gRPC plugin (SocketsHttpHandler) so every TLS-capable transport speaks the same wire format and only one PEM parser exists in the codebase.
public MtlsConfig(string CertificatePem, string PrivateKeyPem, string? Passphrase, string? CaCertificatePem, bool AllowSelfSigned)
Parameters
CertificatePemstringPrivateKeyPemstringPassphrasestringCaCertificatePemstringAllowSelfSignedbool
Fields
MtlsMarkerKey
Magic metadata key the JS mtls auth helper uses to ship its PEM material to plugin invokers. Plugins strip the marker before forwarding the rest of the metadata as protocol-level headers.
public const string MtlsMarkerKey = "__bowireMtls__"
Field Value
Properties
AllowSelfSigned
public bool AllowSelfSigned { get; init; }
Property Value
CaCertificatePem
public string? CaCertificatePem { get; init; }
Property Value
CertificatePem
public string CertificatePem { get; init; }
Property Value
Passphrase
public string? Passphrase { get; init; }
Property Value
PrivateKeyPem
public string PrivateKeyPem { get; init; }
Property Value
Methods
BuildServerValidator(X509Certificate2?)
Build the server-cert validation callback that REST and gRPC handlers
can install on their respective TLS layers. AllowSelfSigned=true
returns a no-op accept-anything; otherwise, when caCert
is supplied, a CA-pinning validator that only forgives
UntrustedRoot / PartialChain errors. Returns null when
neither override applies (system trust store handles validation).
public Func<object?, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? BuildServerValidator(X509Certificate2? caCert)
Parameters
caCertX509Certificate2
Returns
Deconstruct(out string, out string, out string?, out string?, out bool)
public void Deconstruct(out string CertificatePem, out string PrivateKeyPem, out string? Passphrase, out string? CaCertificatePem, out bool AllowSelfSigned)
Parameters
CertificatePemstringPrivateKeyPemstringPassphrasestringCaCertificatePemstringAllowSelfSignedbool
Equals(MtlsConfig?)
public bool Equals(MtlsConfig? other)
Parameters
otherMtlsConfig
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
StripMarker(IReadOnlyDictionary<string, string>?)
Returns a copy of the metadata dict with the magic mTLS marker
removed — plugins call this before forwarding metadata as protocol
headers (gRPC Metadata, HTTP request headers, ...).
public static Dictionary<string, string>? StripMarker(IReadOnlyDictionary<string, string>? metadata)
Parameters
metadataIReadOnlyDictionary<string, string>
Returns
ToString()
public override string ToString()
Returns
TryLoadCertificates(out X509Certificate2?, out X509Certificate2?, out string?)
Decode the PEM material into ready-to-use X509 resources. Returns null if anything fails to parse — caller surfaces a clean error to the user. Caller owns disposal of the returned certificates (or wraps them in a dedicated handler-owner — see MtlsHandlerOwner).
public bool TryLoadCertificates(out X509Certificate2? clientCert, out X509Certificate2? caCert, out string? error)
Parameters
clientCertX509Certificate2caCertX509Certificate2errorstring
Returns
TryParse(string)
Parse the JSON shape produced by the JS auth.js layer:
{ certificate, privateKey, passphrase?, caCertificate?, allowSelfSigned? }.
Empty strings on optional fields collapse to null so the encrypted-PEM
path is only taken when a real passphrase was supplied.
public static MtlsConfig? TryParse(string json)
Parameters
jsonstring
Returns
TryParseFromMetadata(IReadOnlyDictionary<string, string>?)
Look up and parse the marker entry in metadata.
Returns null when the marker is absent or its JSON is malformed.
public static MtlsConfig? TryParseFromMetadata(IReadOnlyDictionary<string, string>? metadata)
Parameters
metadataIReadOnlyDictionary<string, string>
Returns
Operators
operator ==(MtlsConfig?, MtlsConfig?)
public static bool operator ==(MtlsConfig? left, MtlsConfig? right)
Parameters
leftMtlsConfigrightMtlsConfig
Returns
operator !=(MtlsConfig?, MtlsConfig?)
public static bool operator !=(MtlsConfig? left, MtlsConfig? right)
Parameters
leftMtlsConfigrightMtlsConfig