Table of Contents

Class GrpcServer

Namespace
DMediatR
Assembly
DMediatR.dll

Utility for creating a gRPC service WebApplicationBuilder and WebApplication in a DMediatR node.

public static class GrpcServer
Inheritance
GrpcServer
Inherited Members

Properties

ConsoleTitle

For setting the Console.Title in Program.cs. Includes the optional ASPNETCORE_ENVIRONMENT, Host and Port.

public static string ConsoleTitle { get; }

Property Value

string

IntermediateCrt

The intermediate certificate client and server certificates are validated against.

public static X509Certificate2? IntermediateCrt { get; }

Property Value

X509Certificate2

IntermediateCrtOld

The old intermediate certificate client and server certificates were validated against. Used for certificate renewal

public static X509Certificate2? IntermediateCrtOld { get; }

Property Value

X509Certificate2

Logger

public static ILogger<X509Chain>? Logger { get; }

Property Value

ILogger<X509Chain>

Methods

CreateWebApp(WebApplicationBuilder, GrpcPort)

public static WebApplication CreateWebApp(WebApplicationBuilder builder, GrpcPort usePort = GrpcPort.UseDefault)

Parameters

builder WebApplicationBuilder
usePort GrpcPort

Returns

WebApplication

CreateWebAppBuilder(string[], GrpcPort)

public static WebApplicationBuilder CreateWebAppBuilder(string[] args, GrpcPort usePort = GrpcPort.UseDefault)

Parameters

args string[]
usePort GrpcPort

Returns

WebApplicationBuilder

GetHostOptions(string)

Get the Host options outside of the WebApplicationBuilder.

public static HostOptions GetHostOptions(string environment = "")

Parameters

environment string

Returns

HostOptions

LoadIntermediateCertificates(IServiceProvider)

Used only for validation, thus take the .crt file and ignore RenewBeforeExpirationDays.

public static void LoadIntermediateCertificates(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

Exceptions

Exception

RunRestartWebAppAsync(string[], GrpcPort, Action<WebApplicationBuilder>?, CancellationToken)

Build and run the WebApplication, repeat after it was stopped with IHostApplicationLifetime.StopApplication().

public static Task RunRestartWebAppAsync(string[] args, GrpcPort usePort, Action<WebApplicationBuilder>? builderCfg, CancellationToken cancellationToken)

Parameters

args string[]
usePort GrpcPort
builderCfg Action<WebApplicationBuilder>

Optional callback for additional configuration of the WebApplicationBuilder, such as adding a concrete logger.

cancellationToken CancellationToken

Returns

Task

SetUpInitialCertificateChain(Action<ILoggingBuilder>)

Generate or renew the certificate chain by directly using the local services.

public static string SetUpInitialCertificateChain(Action<ILoggingBuilder> configureLogging)

Parameters

configureLogging Action<ILoggingBuilder>

Returns

string

FilePath where the certificate chain was saved.