StellaOps.Router.Transport.Tls

Router TLS transport, client side: connects a microservice to a gateway over TLS, with client certificates.

library
Component
Router
Licence
Apache-2.0
Target framework
net10.0
Latest release
1.0.1-20261117T070237Z

Install

dotnet add package StellaOps.Router.Transport.Tls --version 1.0.1-20261117T070237Z

Namespaces

NamespaceTypes
StellaOps.Router.Transport.Tls12

namespace StellaOps.Router.Transport.Tls

TypeKindDescription
CertificateLoaderclassUtility class for loading certificates from various sources.
CertificatePinningOptionsclassCertificate pinning configuration.
CertificateWatcherclassWatches certificate files for changes and triggers hot-reload.
TlsCertificateValidatorclassStrict TLS certificate validator.
TlsCertificateValidator.ReasonsclassReason codes used in log messages and the rejection counter.
TlsConnectionclassRepresents a TLS-secured connection to a microservice.
TlsTransportClientclassTLS transport client implementation for microservices.
TlsTransportClientServiceCollectionExtensionsclassExtension methods for registering TLS transport services.
TlsTransportOptionsclassOptions for TLS transport configuration.
TlsTransportPluginclassPlugin for the client side of the TLS transport, which a microservice connects with.
TlsValidationDecisionenumDecision returned by TlsCertificateValidator.Validate(X509Certificate, X509Chain, SslPolicyErrors, TlsTransportOptions, bool, string, ILogger).
TlsValidationResultstructResult of running the validator: an TlsValidationDecisionplus a machine-readable rejection reason for logging and the router_tls_validate_rejected_total{reason} counter.

class CertificateLoader

public static class CertificateLoader

Utility class for loading certificates from various sources.

Members

MemberKindSummary
LoadCertificateFromPath(string, string, string)methodLoads a certificate from a file path.
LoadClientCertificate(TlsTransportOptions)methodLoads a client certificate from the options.
LoadServerCertificate(TlsTransportOptions)methodLoads a server certificate from the options.

method LoadCertificateFromPath(string, string, string) #

public static X509Certificate2 LoadCertificateFromPath(string certPath, string? keyPath = null, string? password = null)

Loads a certificate from a file path.

Parameters

  • certPath: The certificate path (PEM or PFX).
  • keyPath: The private key path (optional, for PEM).
  • password: The password (optional, for PFX).

Returns

The loaded certificate.

method LoadClientCertificate(TlsTransportOptions) #

public static X509Certificate2? LoadClientCertificate(TlsTransportOptions options)

Loads a client certificate from the options.

Parameters

  • options: The TLS transport options.

Returns

The loaded certificate, or null if not configured.

method LoadServerCertificate(TlsTransportOptions) #

public static X509Certificate2 LoadServerCertificate(TlsTransportOptions options)

Loads a server certificate from the options.

Parameters

  • options: The TLS transport options.

Returns

The loaded certificate.

Exceptions

  • InvalidOperationException: Thrown when no certificate is configured.

class CertificatePinningOptions

public sealed class CertificatePinningOptions

Certificate pinning configuration. Required when TlsTransportOptions.AllowSelfSignedis true — otherwise the validator would accept any self-signed certificate.

At least one of the three pin sets must be non-empty when self-signed acceptance is enabled. Pin matching is any-of: a presented certificate is acceptable when its SHA-256 thumbprint OR its subject DN OR any of its SAN DNS entries matches an entry in the corresponding allowlist.

Recommended posture, in tightening order: 1. CertificatePinningOptions.ThumbprintsSha256only (leaf-pinning; rotates require config update) 2. Subject pinning to a private CA (leaf rotation without re-pinning) 3. SAN allowlist (loosest; relies on operator-issued cert names)

Members

MemberKindSummary
CertificatePinningOptions()constructorCreates an instance of CertificatePinningOptions.
AllowedSanspropertyAllowed Subject Alternative Name DNS entries.
AllowedSubjectspropertyAllowed subject distinguished names.
IsEmptypropertyReturns true when no pin entries are configured at all.
ThumbprintsSha256propertyAllowed certificate SHA-256 thumbprints, hex-encoded (case-insensitive on input, normalised to upper-case for matching).

constructor CertificatePinningOptions() #

public CertificatePinningOptions()

Creates an instance of CertificatePinningOptions.

property AllowedSans #

public IReadOnlyList<string> AllowedSans { get; init; }

Allowed Subject Alternative Name DNS entries. Compared via StringComparer.Ordinal against entries extracted from the cert’s SAN extension. Wildcard entries are not expanded — provide the exact value.

property AllowedSubjects #

public IReadOnlyList<string> AllowedSubjects { get; init; }

Allowed subject distinguished names. Compared via StringComparer.Ordinal against X509Certificate.Subject. Use the exact RFC-2253 form emitted by .NET (e.g. CN=service-a, O=stellaops).

property IsEmpty #

public bool IsEmpty { get; }

Returns true when no pin entries are configured at all.

property ThumbprintsSha256 #

public IReadOnlyList<string> ThumbprintsSha256 { get; init; }

Allowed certificate SHA-256 thumbprints, hex-encoded (case-insensitive on input, normalised to upper-case for matching). Matching uses StringComparer.Ordinal after normalisation. An empty/whitespace string is ignored.

class CertificateWatcher

public sealed class CertificateWatcher : IDisposable

Watches certificate files for changes and triggers hot-reload.

Members

MemberKindSummary
CertificateWatcher(TlsTransportOptions, ILogger)constructorInitializes a new instance of the CertificateWatcherclass.
ClientCertificatepropertyGets the current client certificate.
ServerCertificatepropertyGets the current server certificate.
OnClientCertificateReloadedeventEvent raised when the client certificate is reloaded.
OnServerCertificateReloadedeventEvent raised when the server certificate is reloaded.
Dispose()methodSee IDisposable.Dispose().

constructor CertificateWatcher(TlsTransportOptions, ILogger) #

public CertificateWatcher(TlsTransportOptions options, ILogger logger)

Initializes a new instance of the CertificateWatcherclass.

property ClientCertificate #

public X509Certificate2? ClientCertificate { get; }

Gets the current client certificate.

property ServerCertificate #

public X509Certificate2? ServerCertificate { get; }

Gets the current server certificate.

event OnClientCertificateReloaded #

public event Action<X509Certificate2>? OnClientCertificateReloaded

Event raised when the client certificate is reloaded.

event OnServerCertificateReloaded #

public event Action<X509Certificate2>? OnServerCertificateReloaded

Event raised when the server certificate is reloaded.

method Dispose() #

public void Dispose()

See IDisposable.Dispose().

class TlsCertificateValidator

public static class TlsCertificateValidator

Strict TLS certificate validator.

Rules, in order: 1. Errors include SslPolicyErrors.RemoteCertificateNotAvailable -> reject. 2. Errors include SslPolicyErrors.RemoteCertificateNameMismatch -> reject unconditionally, regardless of AllowSelfSigned. 3. Errors include SslPolicyErrors.RemoteCertificateChainErrors: - When AllowSelfSigned=false: reject. - When AllowSelfSigned=true: accept only if the chain status is exactly X509ChainStatusFlags.UntrustedRoot or X509ChainStatusFlags.PartialChain (no other status flags) AND the certificate matches the configured pin set. 4. No errors -> accept.

Both sides of the TLS transport apply it: the client to the gateway’s server certificate and the server (StellaOps.Router.Transport.Tls.Server) to a microservice’s client certificate.

Members

MemberKindSummary
MeterNameconstantMeter name for OpenTelemetry exporters.
Validate(X509Certificate, X509Chain, SslPolicyErrors, TlsTransportOptions, bool, string, ILogger)methodRuns the validator and emits structured-log + counter side effects on rejection.

constant MeterName #

public const string MeterName = "StellaOps.Router.Transport.Tls"

Meter name for OpenTelemetry exporters.

method Validate(X509Certificate, X509Chain, SslPolicyErrors, TlsTransportOptions, bool, string, ILogger) #

public static TlsValidationResult Validate(X509Certificate? certificate, X509Chain? chain, SslPolicyErrors errors, TlsTransportOptions options, bool requireCertificate, string role, ILogger logger)

Runs the validator and emits structured-log + counter side effects on rejection.

Parameters

  • certificate: The presented peer certificate, or null.
  • chain: The chain object built by SslStream.
  • errors: The errors raised by the platform validator.
  • options: The transport options carrying pinning / self-signed config.
  • requireCertificate: Whether absence of a certificate is itself a rejection (server side: mTLS required; client side: always required since the gateway always presents one).
  • role: Either "client_certificate" or "server_certificate"; emitted on the counter and in log messages so server-side and client-side rejections can be distinguished in metrics.
  • logger: Logger for warning-level rejection messages.

class TlsCertificateValidator.Reasons

public static class Reasons

Reason codes used in log messages and the rejection counter.

Members

MemberKindSummary
CertificateRequiredButMissingconstantA certificate is required and the peer presented none.
ChainErrorAndSelfSignedDisallowedconstantThe chain does not validate and self-signed certificates are not allowed.
ChainStatusNotPermittedconstantThe chain status is other than an untrusted root or a partial chain.
NameMismatchconstantThe certificate name does not match the peer.
OtherSslPolicyErrorconstantAnother TLS policy error.
PinMismatchconstantThe certificate matches no configured pin.
PinSetEmptyconstantSelf-signed certificates are allowed but no pin is configured.
RemoteCertificateNotAvailableconstantThe platform reported that the remote certificate is not available.

constant CertificateRequiredButMissing #

public const string CertificateRequiredButMissing = "certificate_required_but_missing"

A certificate is required and the peer presented none.

constant ChainErrorAndSelfSignedDisallowed #

public const string ChainErrorAndSelfSignedDisallowed = "chain_error_and_self_signed_disallowed"

The chain does not validate and self-signed certificates are not allowed.

constant ChainStatusNotPermitted #

public const string ChainStatusNotPermitted = "chain_status_not_permitted"

The chain status is other than an untrusted root or a partial chain.

constant NameMismatch #

public const string NameMismatch = "name_mismatch"

The certificate name does not match the peer.

constant OtherSslPolicyError #

public const string OtherSslPolicyError = "other_ssl_policy_error"

Another TLS policy error.

constant PinMismatch #

public const string PinMismatch = "pin_mismatch"

The certificate matches no configured pin.

constant PinSetEmpty #

public const string PinSetEmpty = "pin_set_empty"

Self-signed certificates are allowed but no pin is configured.

constant RemoteCertificateNotAvailable #

public const string RemoteCertificateNotAvailable = "remote_certificate_not_available"

The platform reported that the remote certificate is not available.

class TlsConnection

public sealed class TlsConnection : IAsyncDisposable

Represents a TLS-secured connection to a microservice.

Members

MemberKindSummary
TlsConnection(string, TcpClient, SslStream, TlsTransportOptions, ILogger)constructorInitializes a new instance of the TlsConnectionclass.
ConnectionIdpropertyGets the connection ID.
ConnectionTokenpropertyGets the cancellation token for this connection.
IsConnectedpropertyGets a value indicating whether the connection is active.
PeerIdentitypropertyGets the peer identity extracted from the certificate.
RemoteCertificatepropertyGets the remote certificate (if mTLS).
RemoteEndpointpropertyGets the remote endpoint as a string.
StatepropertyGets the connection state.
OnDisconnectedeventEvent raised when the connection is closed.
OnFrameReceivedeventEvent raised when a frame is received.
Close()methodCloses the connection.
DisposeAsync()methodSee IAsyncDisposable.DisposeAsync().
ReadLoopAsync(CancellationToken)methodStarts the read loop to receive frames.
WriteFrameAsync(Frame, CancellationToken)methodWrites a frame to the connection.

constructor TlsConnection(string, TcpClient, SslStream, TlsTransportOptions, ILogger) #

public TlsConnection(string connectionId, TcpClient client, SslStream sslStream, TlsTransportOptions options, ILogger logger)

Initializes a new instance of the TlsConnectionclass.

property ConnectionId #

public string ConnectionId { get; }

Gets the connection ID.

property ConnectionToken #

public CancellationToken ConnectionToken { get; }

Gets the cancellation token for this connection.

property IsConnected #

public bool IsConnected { get; }

Gets a value indicating whether the connection is active.

property PeerIdentity #

public string? PeerIdentity { get; }

Gets the peer identity extracted from the certificate.

property RemoteCertificate #

public X509Certificate? RemoteCertificate { get; }

Gets the remote certificate (if mTLS).

property RemoteEndpoint #

public string RemoteEndpoint { get; }

Gets the remote endpoint as a string.

property State #

public ConnectionState? State { get; set; }

Gets the connection state.

event OnDisconnected #

public event Action<TlsConnection, Exception?>? OnDisconnected

Event raised when the connection is closed.

event OnFrameReceived #

public event Action<TlsConnection, Frame>? OnFrameReceived

Event raised when a frame is received.

method Close() #

public void Close()

Closes the connection.

method DisposeAsync() #

public ValueTask DisposeAsync()

See IAsyncDisposable.DisposeAsync().

method ReadLoopAsync(CancellationToken) #

public Task ReadLoopAsync(CancellationToken cancellationToken)

Starts the read loop to receive frames.

Parameters

  • cancellationToken: Cancellation token.

method WriteFrameAsync(Frame, CancellationToken) #

public Task WriteFrameAsync(Frame frame, CancellationToken cancellationToken = default)

Writes a frame to the connection.

Parameters

  • frame: The frame to write.
  • cancellationToken: Cancellation token.

class TlsTransportClient

public sealed class TlsTransportClient : ITransportClient, IMicroserviceTransport, IAsyncDisposable

TLS transport client implementation for microservices.

Members

MemberKindSummary
TlsTransportClient(IOptions<TlsTransportOptions>, ILogger<TlsTransportClient>)constructorInitializes a new instance of the TlsTransportClientclass.
OnCancelReceivedeventEvent raised when a CANCEL frame is received.
OnRequestReceivedeventEvent raised when a REQUEST frame is received.
TransportDiedeventRaised once when the connection is lost and TlsTransportOptions.MaxReconnectAttemptsreconnects have failed.
CancelAllInflight(string)methodCancels all in-flight handlers.
ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, CancellationToken)methodConnects to the gateway.
ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, IReadOnlyDictionary<string, SchemaDefinition>, ServiceOpenApiInfo, CancellationToken)methodConnects to the gateway and registers the instance, its endpoints, schemas and OpenAPI metadata in the HELLO frame.
DisconnectAsync()methodDisconnects from the gateway.
DisposeAsync()methodSee IAsyncDisposable.DisposeAsync().
SendCancelAsync(ConnectionState, Guid, string)methodSends a cancellation request.
SendHeartbeatAsync(HeartbeatPayload, CancellationToken)methodSends a heartbeat.
SendRequestAsync(ConnectionState, Frame, TimeSpan, CancellationToken)methodSends a request and waits for a response.
SendStreamingAsync(ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken)methodSends a request whose body is read from a stream and hands the microservice’s response to readResponse.

constructor TlsTransportClient(IOptions<TlsTransportOptions>, ILogger<TlsTransportClient>) #

public TlsTransportClient(IOptions<TlsTransportOptions> options, ILogger<TlsTransportClient> logger)

Initializes a new instance of the TlsTransportClientclass.

event OnCancelReceived #

public event Func<Guid, string?, Task>? OnCancelReceived

Event raised when a CANCEL frame is received.

event OnRequestReceived #

public event Func<Frame, CancellationToken, Task<Frame>>? OnRequestReceived

Event raised when a REQUEST frame is received.

event TransportDied #

public event Action? TransportDied

Raised once when the connection is lost and TlsTransportOptions.MaxReconnectAttemptsreconnects have failed. The service’s connection manager then connects again with its own back-off until the gateway answers or the service stops.

method CancelAllInflight(string) #

public void CancelAllInflight(string reason)

Cancels all in-flight handlers.

method ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, CancellationToken) #

public Task ConnectAsync(InstanceDescriptor instance, IReadOnlyList<EndpointDescriptor> endpoints, CancellationToken cancellationToken)

Connects to the gateway.

Parameters

  • instance: The instance descriptor.
  • endpoints: The endpoints to register.
  • cancellationToken: Cancellation token.

method ConnectAsync(InstanceDescriptor, IReadOnlyList<EndpointDescriptor>, IReadOnlyDictionary<string, SchemaDefinition>, ServiceOpenApiInfo, CancellationToken) #

public Task ConnectAsync(InstanceDescriptor instance, IReadOnlyList<EndpointDescriptor> endpoints, IReadOnlyDictionary<string, SchemaDefinition>? schemas, ServiceOpenApiInfo? openApiInfo, CancellationToken cancellationToken)

Connects to the gateway and registers the instance, its endpoints, schemas and OpenAPI metadata in the HELLO frame.

Parameters

  • instance: The instance descriptor.
  • endpoints: The endpoints to register.
  • schemas: Schema definitions referenced by the endpoints.
  • openApiInfo: OpenAPI metadata for the service.
  • cancellationToken: Cancellation token.

method DisconnectAsync() #

public Task DisconnectAsync()

Disconnects from the gateway.

method DisposeAsync() #

public ValueTask DisposeAsync()

See IAsyncDisposable.DisposeAsync().

method SendCancelAsync(ConnectionState, Guid, string) #

public Task SendCancelAsync(ConnectionState connection, Guid correlationId, string? reason = null)

Sends a cancellation request.

Parameters

  • connection: The connection to use.
  • correlationId: The correlation ID of the request to cancel.
  • reason: Optional reason for cancellation.

method SendHeartbeatAsync(HeartbeatPayload, CancellationToken) #

public Task SendHeartbeatAsync(HeartbeatPayload heartbeat, CancellationToken cancellationToken)

Sends a heartbeat.

method SendRequestAsync(ConnectionState, Frame, TimeSpan, CancellationToken) #

public Task<Frame> SendRequestAsync(ConnectionState connection, Frame requestFrame, TimeSpan timeout, CancellationToken cancellationToken)

Sends a request and waits for a response.

Parameters

  • connection: The connection to use.
  • requestFrame: The request frame.
  • timeout: The timeout for the request.
  • cancellationToken: Cancellation token.

Returns

The response frame.

method SendStreamingAsync(ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken) #

public Task SendStreamingAsync(ConnectionState connection, Frame requestHeader, Stream requestBody, Func<ResponseFrame, Stream, Task> readResponse, PayloadLimits limits, CancellationToken cancellationToken)

Sends a request whose body is read from a stream and hands the microservice’s response to readResponse. TransportStreamingDispatch.SendBufferedAsync(ITransportClient, ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken)implements it for transports whose microservice side answers a request with one response frame.

Parameters

  • connection: The connection to use.
  • requestHeader: The request header frame.
  • requestBody: The request body stream.
  • readResponse: Callback that receives the response head (the status code and headers of the microservice’s response; its ResponseFrame.Payloadis empty) and the response body stream.
  • limits: Payload limits to enforce.
  • cancellationToken: Cancellation token.

Remarks

Sends the request body in one request frame (TransportStreamingDispatch.SendBufferedAsync(ITransportClient, ConnectionState, Frame, Stream, Func<ResponseFrame, Stream, Task>, PayloadLimits, CancellationToken)).

class TlsTransportClientServiceCollectionExtensions

public static class TlsTransportClientServiceCollectionExtensions

Extension methods for registering TLS transport services.

Members

MemberKindSummary
AddTlsTransportClient(IServiceCollection, Action<TlsTransportOptions>)extension methodAdds the TLS transport client to the service collection.

extension method AddTlsTransportClient(IServiceCollection, Action<TlsTransportOptions>) #

public static IServiceCollection AddTlsTransportClient(this IServiceCollection services, Action<TlsTransportOptions>? configure = null)

Adds the TLS transport client to the service collection.

Parameters

  • services: The service collection.
  • configure: Configuration action.

Returns

The service collection.

class TlsTransportOptions

public sealed class TlsTransportOptions

Options for TLS transport configuration.

Members

MemberKindSummary
TlsTransportOptions()constructorCreates an instance of TlsTransportOptions.
AllowSelfSignedpropertyGets or sets whether to allow self-signed certificates (dev only).
BindAddresspropertyGets or sets the bind address for the server.
CertificatePinningpropertyCertificate pinning configuration.
CheckCertificateRevocationpropertyGets or sets whether to check certificate revocation.
ClientCertificatepropertyGets or sets the client certificate object.
ClientCertificateKeyPathpropertyGets or sets the client certificate key path (PEM private key).
ClientCertificatePasswordpropertyGets or sets the client certificate password (for PFX).
ClientCertificatePathpropertyGets or sets the client certificate path (PEM or PFX).
ConnectTimeoutpropertyGets or sets the connection timeout.
EnableCertificateHotReloadpropertyGets or sets whether to enable certificate hot-reload.
EnabledProtocolspropertyGets or sets the enabled SSL/TLS protocols.
ExpectedServerHostnamepropertyGets or sets the expected server hostname (for SNI).
HostpropertyGets or sets the host to connect to (client only).
KeepAliveIntervalpropertyGets or sets the TCP keep-alive interval of the connection’s socket, on the service and on the gateway: after this long without traffic the operating system probes the peer, probes again every interval and closes the connection after three unanswered probes, so a peer that vanished without closing the connection is noticed.
MaxFrameSizepropertyGets or sets the maximum frame size.
MaxReconnectAttemptspropertyGets or sets the number of reconnection attempts after a lost connection, with the capped back-off of TlsTransportOptions.MaxReconnectBackoff.
MaxReconnectBackoffpropertyGets or sets the maximum reconnection backoff.
PortpropertyGets or sets the port to listen on, or the gateway port a client connects to.
ReceiveBufferSizepropertyGets or sets the receive buffer size.
RequireClientCertificatepropertyGets or sets whether to require client certificates (mTLS).
SendBufferSizepropertyGets or sets the send buffer size.
ServerCertificatepropertyGets or sets the server certificate object.
ServerCertificateKeyPathpropertyGets or sets the server certificate key path (PEM private key).
ServerCertificatePasswordpropertyGets or sets the server certificate password (for PFX).
ServerCertificatePathpropertyGets or sets the server certificate path (PEM or PFX).
Validate()methodValidates the option combination and throws InvalidOperationException if the configuration would accept any self-signed certificate (self-signed acceptance without a pin set).

constructor TlsTransportOptions() #

public TlsTransportOptions()

Creates an instance of TlsTransportOptions.

property AllowSelfSigned #

public bool AllowSelfSigned { get; set; }

Gets or sets whether to allow self-signed certificates (dev only).

property BindAddress #

public IPAddress BindAddress { get; set; }

Gets or sets the bind address for the server.

property CertificatePinning #

public CertificatePinningOptions CertificatePinning { get; set; }

Certificate pinning configuration. Required when TlsTransportOptions.AllowSelfSignedis true: without a pin set, that validator would accept any self-signed certificate, so startup fails with a descriptive error when self-signed acceptance has no pin set.

When TlsTransportOptions.AllowSelfSignedis false, pinning is optional but still applied as a defence-in-depth check on top of standard chain validation.

property CheckCertificateRevocation #

public bool CheckCertificateRevocation { get; set; }

Gets or sets whether to check certificate revocation.

property ClientCertificate #

public X509Certificate2? ClientCertificate { get; set; }

Gets or sets the client certificate object.

property ClientCertificateKeyPath #

public string? ClientCertificateKeyPath { get; set; }

Gets or sets the client certificate key path (PEM private key).

property ClientCertificatePassword #

public string? ClientCertificatePassword { get; set; }

Gets or sets the client certificate password (for PFX).

property ClientCertificatePath #

public string? ClientCertificatePath { get; set; }

Gets or sets the client certificate path (PEM or PFX).

property ConnectTimeout #

public TimeSpan ConnectTimeout { get; set; }

Gets or sets the connection timeout.

property EnableCertificateHotReload #

public bool EnableCertificateHotReload { get; set; }

Gets or sets whether to enable certificate hot-reload.

property EnabledProtocols #

public SslProtocols EnabledProtocols { get; set; }

Gets or sets the enabled SSL/TLS protocols.

property ExpectedServerHostname #

public string? ExpectedServerHostname { get; set; }

Gets or sets the expected server hostname (for SNI).

property Host #

public string? Host { get; set; }

Gets or sets the host to connect to (client only).

property KeepAliveInterval #

public TimeSpan KeepAliveInterval { get; set; }

Gets or sets the TCP keep-alive interval of the connection’s socket, on the service and on the gateway: after this long without traffic the operating system probes the peer, probes again every interval and closes the connection after three unanswered probes, so a peer that vanished without closing the connection is noticed. Zero or a negative value turns keep-alive off. Whole seconds, rounded up. Default: 30 seconds.

property MaxFrameSize #

public int MaxFrameSize { get; set; }

Gets or sets the maximum frame size.

property MaxReconnectAttempts #

public int MaxReconnectAttempts { get; set; }

Gets or sets the number of reconnection attempts after a lost connection, with the capped back-off of TlsTransportOptions.MaxReconnectBackoff. When they all fail, the client raises TlsTransportClient.TransportDiedand the service’s connection manager connects again with its own back-off until the gateway answers or the service stops; the service is never left disconnected. Default: 10.

property MaxReconnectBackoff #

public TimeSpan MaxReconnectBackoff { get; set; }

Gets or sets the maximum reconnection backoff.

property Port #

public int Port { get; set; }

Gets or sets the port to listen on, or the gateway port a client connects to. Default: TransportDefaultPorts.Tls(9443), the gateway options’ default.

property ReceiveBufferSize #

public int ReceiveBufferSize { get; set; }

Gets or sets the receive buffer size.

property RequireClientCertificate #

public bool RequireClientCertificate { get; set; }

Gets or sets whether to require client certificates (mTLS).

property SendBufferSize #

public int SendBufferSize { get; set; }

Gets or sets the send buffer size.

property ServerCertificate #

public X509Certificate2? ServerCertificate { get; set; }

Gets or sets the server certificate object.

property ServerCertificateKeyPath #

public string? ServerCertificateKeyPath { get; set; }

Gets or sets the server certificate key path (PEM private key).

property ServerCertificatePassword #

public string? ServerCertificatePassword { get; set; }

Gets or sets the server certificate password (for PFX).

property ServerCertificatePath #

public string? ServerCertificatePath { get; set; }

Gets or sets the server certificate path (PEM or PFX).

method Validate() #

public void Validate()

Validates the option combination and throws InvalidOperationException if the configuration would accept any self-signed certificate (self-signed acceptance without a pin set). Called by TlsTransportServer (StellaOps.Router.Transport.Tls.Server) and TlsTransportClientat startup.

class TlsTransportPlugin

public sealed class TlsTransportPlugin : IRouterTransportPlugin

Plugin for the client side of the TLS transport, which a microservice connects with. The server side is TlsTransportServerPlugin in StellaOps.Router.Transport.Tls.Server; both carry the transport name tls.

Members

MemberKindSummary
TlsTransportPlugin()constructorCreates an instance of TlsTransportPlugin.
DisplayNamepropertyGets the human-readable display name for this transport.
ModepropertyGets the side of the transport this plugin registers: RouterTransportMode.Client, RouterTransportMode.Server, or RouterTransportMode.Both.
TransportNamepropertyGets the transport name (e.g., “tcp”, “tls”, “udp”, “rabbitmq”, “inmemory”, “messaging”), shared by the client and the server plugin of one transport.
Register(RouterTransportRegistrationContext)methodRegisters transport services into the DI container for the side the context asks for.
RegisterShared(RouterTransportRegistrationContext)methodThe registration the client and the server plugin of the TLS transport share: the TlsTransportOptionsbinding of the context’s configuration section (Router:Transport:Tls when the context names none).

constructor TlsTransportPlugin() #

public TlsTransportPlugin()

Creates an instance of TlsTransportPlugin.

property DisplayName #

public string DisplayName { get; }

Gets the human-readable display name for this transport.

property Mode #

public RouterTransportMode Mode { get; }

Gets the side of the transport this plugin registers: RouterTransportMode.Client, RouterTransportMode.Server, or RouterTransportMode.Both. IRouterTransportPlugin.Register(RouterTransportRegistrationContext)refuses a context that asks for a side outside this value (RouterTransportRegistrationContext.EnsureSupportedBy(IRouterTransportPlugin)).

property TransportName #

public string TransportName { get; }

Gets the transport name (e.g., “tcp”, “tls”, “udp”, “rabbitmq”, “inmemory”, “messaging”), shared by the client and the server plugin of one transport.

method Register(RouterTransportRegistrationContext) #

public void Register(RouterTransportRegistrationContext context)

Registers transport services into the DI container for the side the context asks for.

Parameters

  • context: The registration context containing services, configuration, and transport mode.

Exceptions

  • InvalidOperationException: The context asks for a side this plugin does not provide.

method RegisterShared(RouterTransportRegistrationContext) #

public static void RegisterShared(RouterTransportRegistrationContext context)

The registration the client and the server plugin of the TLS transport share: the TlsTransportOptionsbinding of the context’s configuration section (Router:Transport:Tls when the context names none). Both plugins call it from TlsTransportPlugin.Register(RouterTransportRegistrationContext); a plugin for either side of the transport calls it the same way.

Parameters

  • context: The registration context of the plugin.

enum TlsValidationDecision

public enum TlsValidationDecision

Decision returned by TlsCertificateValidator.Validate(X509Certificate, X509Chain, SslPolicyErrors, TlsTransportOptions, bool, string, ILogger).

ValueDescription
Accept = 0Validation passed; the certificate is trusted.
Reject = 1Validation failed; the certificate must be rejected.

struct TlsValidationResult

public readonly struct TlsValidationResult : IEquatable<TlsValidationResult>

Result of running the validator: an TlsValidationDecisionplus a machine-readable rejection reason for logging and the router_tls_validate_rejected_total{reason} counter.

Parameters

Members

MemberKindSummary
TlsValidationResult(TlsValidationDecision, string)constructorResult of running the validator: an TlsValidationDecisionplus a machine-readable rejection reason for logging and the router_tls_validate_rejected_total{reason} counter.
DecisionpropertyWhether the certificate is accepted.
ReasonpropertyThe rejection reason, one of TlsCertificateValidator.Reasons; not set on acceptance.

constructor TlsValidationResult(TlsValidationDecision, string) #

public TlsValidationResult(TlsValidationDecision Decision, string? Reason)

Result of running the validator: an TlsValidationDecisionplus a machine-readable rejection reason for logging and the router_tls_validate_rejected_total{reason} counter.

Parameters

property Decision #

public TlsValidationDecision Decision { get; init; }

Whether the certificate is accepted.

property Reason #

public string? Reason { get; init; }

The rejection reason, one of TlsCertificateValidator.Reasons; not set on acceptance.