Skip to content

Add server certificate to AddIceRpcServer docfx examples #4218

@bernardnormier

Description

@bernardnormier

The docfx examples for ServerServiceCollectionExtensions / AddIceRpcServer don't show the installation of the server certificate.

See GenericHost example for the proper setup:

        // Load and register the server certificate as a singleton so it stays alive and gets disposed.
        services.AddSingleton<X509Certificate2>(sp =>
            X509CertificateLoader.LoadPkcs12FromFile(
                Path.Combine(
                    hostContext.HostingEnvironment.ContentRootPath,
                    hostContext.Configuration.GetValue<string>("Certificate:File")!),
                password: null,
                keyStorageFlags: X509KeyStorageFlags.Exportable));

        // Bind the server options to the "appsettings.json" configuration "Server" section, and add a Configure
        // callback to configure its authentication options.
        services
            .AddOptions<ServerOptions>()
            .Bind(hostContext.Configuration.GetSection("Server"))
            .Configure<X509Certificate2>((options, serverCertificate) =>
                options.ServerAuthenticationOptions = CreateServerAuthenticationOptions(serverCertificate));

As a result, these docfx examples are incomplete and potentially confusing.

For the GenericHost example, we use a helper to create the server authentication options, but not the the docfx examples. Maybe we should add this helper to the docfx examples?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions