Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify configuration provider capabilities for Kestrel options #16759

Closed
javs-ctr opened this issue Jan 29, 2020 — with docs.microsoft.com · 3 comments · Fixed by #16889
Closed

Clarify configuration provider capabilities for Kestrel options #16759

javs-ctr opened this issue Jan 29, 2020 — with docs.microsoft.com · 3 comments · Fixed by #16889
Assignees
Labels
doc-enhancement Pri2 Priority 2 product-question Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

javs-ctr commented Jan 29, 2020

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.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Jan 29, 2020
@guardrex
Copy link
Collaborator

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 ☝️ 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.

@javs-ctr
Copy link
Author

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.

@guardrex
Copy link
Collaborator

See: dotnet/aspnetcore#18660 (comment)

@guardrex guardrex reopened this Jan 29, 2020
@guardrex guardrex self-assigned this Jan 29, 2020
@guardrex guardrex added this to To do in February 2020 via automation Jan 29, 2020
@guardrex guardrex added this to the 2020 Q1 ends Mar 31 milestone Jan 29, 2020
@guardrex guardrex moved this from To do to Next up in February 2020 Jan 29, 2020
@guardrex guardrex changed the title Kestrel options ... can also be set using a configuration provider... from an appsettings.json ... file Clarify configuration provider capabilities for Kestrel options Jan 29, 2020
@guardrex guardrex moved this from Next up to In progress in February 2020 Feb 6, 2020
February 2020 automation moved this from In progress to Done Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Pri2 Priority 2 product-question Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
No open projects
February 2020
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants