Path: redb-route/redb.Route.Grpc/GrpcConnectionFactory.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Grpc/GrpcConnectionFactory.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.Grpc;
///
/// Named connection factory for gRPC. Register it in the route registry and reference it by name
/// from the endpoint URI (connectionFactory=my-grpc) so the TLS certificate password never
/// has to appear in the URI, and therefore can never reach logs, telemetry, or the dashboard.
///
/// The listen/target address stays in the endpoint path — a factory carries TLS material only and
/// can never silently redirect a route.
///
///
public sealed class GrpcConnectionFactory
{
/// Serve/connect over TLS.
public bool Ssl { get; set; }
/// Path to the PFX certificate.
public string? SslCertPath { get; set; }
/// Password for the PFX certificate.
[Sensitive]
public string? SslCertPassword { get; set; }
///
/// Copies this factory's TLS settings onto the endpoint options, but only for parameters the
/// endpoint URI did not set explicitly — an inline URI value always wins.
///
internal void ApplyTo(GrpcEndpointOptions options, EndpointUri uri)
{
var supplied = uri.RawParameters;
if (!supplied.ContainsKey(nameof(options.Ssl))) options.Ssl = Ssl;
if (!supplied.ContainsKey(nameof(options.SslCertPath))) options.SslCertPath = SslCertPath;
if (!supplied.ContainsKey(nameof(options.SslCertPassword)))
options.SslCertPassword = SslCertPassword;
}
}