Aspnetcore.docs: Clarify configuration provider capabilities for Kestrel options

Created on 29 Jan 2020  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

Question regarding the statement above under the Kestrel options section:

Kestrel options, which are configured in C# code in the following examples, can also be set using a configuration provider. For example, the File Configuration Provider can load Kestrel configuration from an appsettings.json or appsettings.{Environment}.json file:

In reading the statement above, I am curious if it is possible to set the ClientCertificateMode from the HttpsConnectionAdapterOptions class HttpsConnectionAdapterOptions.cs from an _appsettings.json_ file.

I have tried:

  1 {
  2   "Kestrel": {
  3     "HttpsDefaults": {
  4       "ClientCertificateMode": "AllowCertificate"
  5     }
  6 }

in an _appsettings.json_ file to no avail.

Yet, I am able to configure the ClientCertificateMode Kestrel option from C# code as follows (in Program.cs):

hostBuilder.ConfigureWebHostDefaults(webBuilder =>
{
  webBuilder.UseStartup<Startup>();
  webBuilder.ConfigureKestrel(o =>
  {
    o.ConfigureHttpsDefaults(o =>
      o.ClientCertificateMode =
        ClientCertificateMode.AllowCertificate);
  });
});

I did observe in the Endpoint configuration section above that there is an _appsettings.json_ file example configuring the EndpointDefaults property of the KestrelServerOptions class, which is a sibling property of the HttpsDefaults property, and I inferred that it should also be possible to configure the HttpsDefaults property from an _appsettings.json_ file.

Thank you in advance for any information you are able to provide.

Thank you for the detailed documentation.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P2 Source - Docs.ms doc-enhancement product-question

All 3 comments

Hello @javs-ctr ... Indeed, there isn't exact parity between the naming of properties that you can set in code and the keys used in the configuration file. I don't think that one is available ...

https://github.com/dotnet/aspnetcore/blob/master/src/Servers/Kestrel/Core/src/Internal/ConfigurationReader.cs

However, it's best to ask. Even if it isn't available, your feedback is important to them for framework design. Open a new issue with exactly what you posted :point_up: at ...

https://github.com/dotnet/aspnetcore/issues

Please add a "cc: @guardrex" to the bottom of your opening comment so that I can see what they say.

My thanks to you guardrex for the rapid response. I created an issue earlier based on your recommendation.

The ConfigurationReader.cs class reference was quite helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sonichanxiao picture sonichanxiao  Â·  3Comments

davisnw picture davisnw  Â·  3Comments

Raghumu picture Raghumu  Â·  3Comments

StevenTCramer picture StevenTCramer  Â·  3Comments

Rick-Anderson picture Rick-Anderson  Â·  3Comments