-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Setting the ClientCertificateMode Kestrel server option from an appsettings.json file. #18660
Comments
This is something we'd considered (#4765) but were waiting to see if anybody needed it. |
Greetings Tratcher, thank you for linking to the issue regarding the reading of additional Anyway, to be honest, configuring Additionally, I would like to also +1 both mikkelblanne's comment and RehanSaeed's comment on issue #4765 noting their surprise when following the Kestrel documentation, expecting all Kestrel Server Options to be configurable from a configuration file, and finding out that only a subset of these options are configurable from a configuration file (reference ConfigurationReader.cs). Unsolicited suggestion: Update the Kestrel web server implementation in ASP.NET Core document section Kestrel options that introduces the idea that Kestrel Server Options may be configured with a File Configuration Provider:
with an additional note / reference to the |
I'll take care of that @javs-ctr. I'll re-open your original issue and work it from there. Instead of a reference source link, which is difficult for us to maintain release-to-release, I'll indicate that configuration shown in the example appsettings.json file in the topic's text encompasses all of the available settings that can be configured from a config provider (and I'll confirm that that's actually the case when I work the issue or else add missing keys). |
It's a legitimate ask, and a relative easy property to map from config. |
looks interesting to me. Can I pick this one up? |
@kuns200 feel free. |
Came here looking for the same information in the docs and see there's an open PR, hope to see this! In my case, I actualy only want ClientCertificate auth in Production because I am using Cloudflare's Authenticated Origin Pulls which requires a client certificate.
I need a way to only apply this setting in .ConfigureKestrel(options =>
{
var env = options.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
if (env.IsProduction())
{
options.ConfigureHttpsDefaults(opt =>
opt.ClientCertificateMode =
ClientCertificateMode.RequireCertificate);
}
}) |
Creating this issue was recommended to me from a response to the AspNetCore.Docs issue #16759 I created previously.
Context: From the Microsoft Docs entry for the Kestrel web server implementation in ASP.NET Core, under the Kestrel options section, the following is a description about configuring Kestrel options:
I would like to use the Kestrel web server for local development and IIS for the remote web hosting of an ASP.NET Core web application.
I have successfully followed the Configure your host to require certificates in
Program.cs
for the Kestrel web server.Issue: It would be nice to be able to configure the
ClientCertificateMode
property of theHttpsConnectionAdapterOptions
class from an appsettings.json file, somewhat similar to how theEndpointsDefault
property is configured in the appsettings.json file, documented in the Endpoint configuration section of the Kestrel Microsoft Docs entry. TheEndpointsDefault
property is a sibling property of theHttpsDefaults
property in theKestrelServerOptions
class, and I made an (incorrect) assumption that it would be configurable from an appsettings.json file.In the response to the previous Microsoft Docs issue I created, the
ConfigurationReader.cs
class was linked, providing a Rosetta Stone like tool for comprehending the mapping between theKestrelServerOptions
class members and the corresponding appsettings.json configuration file keys and values. While theHttpsDefaults
key is not found in theConfigurationReader
class like theEndpointDefaults
key, might there be in a future update the addition of theHttpsDefaults
key with the option to set theClientCertificateMode
configuration value?cc: @guardrex
The text was updated successfully, but these errors were encountered: