Path: redb-route/redb.Route.Http.Hosting/HttpHostingOptions.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.Http.Hosting/HttpHostingOptions.cs ---- using System.Security.Claims; using Microsoft.AspNetCore.Http; namespace redb.Route.Http; /// /// Process-wide settings of the shared Kestrel host. One instance serves every listener the /// opens, because the things configured here (which proxies /// to trust) describe the deployment the process runs in, not any single route. /// /// /// /// services.AddRedbRouteHttpHosting(o => o.TrustedProxies.Add("10.0.0.5").Add("10.1.0.0/16")); /// /// public sealed class HttpHostingOptions { /// Reverse proxies allowed to set the client address and scheme. Empty by default. public TrustedProxyOptions TrustedProxies { get; } = new(); /// Server-wide TLS material, used by listeners whose endpoint does not carry its own. public ServerTlsOptions Tls { get; } = new(); /// Kestrel connection ceilings applied to every listener the manager opens. public HostConnectionLimits Limits { get; } = new(); /// /// Identifies the caller of each request on every listener the manager opens. Null (the default) /// leaves requests unidentified and the host byte-for-byte what it was. /// /// It runs once per request: after trusted-proxy resolution, so it sees the client's real address /// and scheme; after CORS, so a preflight never reaches it; and before any transport sees the /// request. A non-null result is kept in HttpContext.Items under /// , and the HTTP, gRPC, SOAP, AS2, WebSocket and /// SignalR consumers put it on the exchange (ExchangePrincipal). /// /// /// It identifies; it does not authorize. Return null for an anonymous caller: such a request /// is still served, because one listener carries routes with different requirements, and whether /// an anonymous caller is acceptable is each route's decision. A resolver that throws fails the /// request with 500 and an error log instead — one that could not decide must not quietly hand the /// route an anonymous caller that may not be one. Build the identity with an authentication type /// (new ClaimsIdentity(claims, "Bearer")): code that reads the principal treats an identity that /// is not authenticated as anonymous. /// /// /// A transport's own authenticate hook (WsComponent.Authenticate, /// SignalRComponent.Authenticate) takes precedence on that transport's paths. /// /// /// /// /// services.AddRedbRouteHttpHosting(o => o.ResolvePrincipal = ctx => /// myTokenValidator.ValidateAsync(ctx.Request.Headers.Authorization.ToString())); /// /// public Func>? ResolvePrincipal { get; set; } } /// /// Coarse host-wide backstop: Kestrel's own connection ceilings, applied to every listener this /// process opens. Kestrel's defaults are unlimited; these protect the whole port. The fine-grained /// tool is the per-route admission limit () — this is the /// fuse, not the thermostat. /// public sealed class HostConnectionLimits { /// Maximum concurrent connections per listener. Null (default) = Kestrel default (unlimited). public long? MaxConcurrentConnections { get; set; } /// /// Maximum concurrent upgraded connections (WebSockets) per listener. /// Null (default) = Kestrel default (unlimited). /// public long? MaxConcurrentUpgradedConnections { get; set; } } /// /// The host's own TLS material. A listener that asks for TLS resolves its certificate from the /// endpoint first (sslCertPath, or a named connection factory), and falls back to what is /// set here — the same shape as Camel's global SSLContextParameters and Spring Boot's SSL /// bundles, where a certificate on the endpoint is an override rather than a requirement. /// /// Nothing here turns TLS on: ssl stays an explicit per-endpoint decision. This only /// answers "with which certificate". A listener that asks for TLS and finds no certificate in /// either place refuses to bind. /// /// /// /// /// services.AddRedbRouteHttpHosting(o => o.Tls.DefaultCertificatePath = "/certs/server.pfx"); /// /// public sealed class ServerTlsOptions { /// /// Certificate served by any TLS listener that has none of its own. Takes precedence over /// , which is the convenience form of the same thing. /// public System.Security.Cryptography.X509Certificates.X509Certificate2? DefaultCertificate { get; set; } /// Path to a PFX file serving the same role as . public string? DefaultCertificatePath { get; set; } /// Password for . public string? DefaultCertificatePassword { get; set; } /// True when the host can supply a certificate to a listener that has none. internal bool HasDefault => DefaultCertificate is not null || !string.IsNullOrEmpty(DefaultCertificatePath); }