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.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
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 ...
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.