-
Notifications
You must be signed in to change notification settings - Fork 523
Make it easier to configure Kestrel endpoints from config #1290
Comments
- Will revisit when aspnet/KestrelHttpServer#1290 is addressed
- Will revisit when aspnet/KestrelHttpServer#1290 is addressed
- Will revisit when aspnet/KestrelHttpServer#1290 is addressed
Removing from Backlog as @danroth27 asked about scenarios (4) and (5). We'll need to discuss this. |
We need to be able to configure SSL for a couple of our templates:
|
@danroth27 You realize none of the above works with IIS right? |
@davidfowl True, but configuring https in IIS is a reasonably addressed problem. |
@davidfowl Also, SSL, port etc should be easier to configure if Kestrel becomes an "edge" server. |
In my mind the key thing here is to allow |
@danroth27 Could you showcase the template changes for this one? @davidfowl wants to see this before committing to a design :) |
@shirhatti FYI |
I think we would add code that looks something like this: webHostBuilder.UseKestrel((context, options) =>
{
options.UseHttps(context.Configuration.GetSection("KestrelHttps");
}); And then we would add the SSL certificate to use for development in appsettings.Development.json. |
Also, we'd like to be able to specify the certificate from a certificate store in configuration. The current user store in particular is supported cross platform in .NET Core. The recommendation from @blowdart is to specify the certificate you want by subject name and then pick the matching cert whose expiry date is furthest in the future. |
Looks like this issue requires aspnet/Hosting#1014 |
@danroth27 That code sample is sufficiently vague. It doesn't actually show how kestrel is configured. We can do the bare minimum and expose access to configuration and then talk about next steps. |
Chatted with @DamianEdwards and we think Kestrel should just bind its options to the config in DI by default: #1703 |
|
2.1 Improvements made so far:
No direct improvement:
Or full config file:
See 3. and 4. above.
Or config:
No code improvements, but better in config:
Or the existing: |
We're going to call this good for 2.1. Please open new issues if there are still painful gaps. |
#1280 added new KestrelServerOptions.Listen APIs for directly configuring kestrel to listen on IPs and ports. However, it's non-trivial to parse these values from config so they can be passed to the new methods. @shirhatti @DamianEdwards
Basic scenarios:
Update the samples to use values passed in via config rather than hardcoded values.
Current API/Sample:
Proposals:
if (!string.IsNullOrEmpty(config["certPath"])) { listenOptions.UseHttps(config["certPath"], config["certPassword"]); }
options.ListenLoopback(int.Parse(config["port"], CultureInfo.InvariantCulture));
vsoptions.ListenLoopback(config["port"]);
options.ListenAny(int.Parse(config["port"], CultureInfo.InvariantCulture));
vsoptions.ListenAny(config["port"]);
options.Listen(IPAddress.Parse(config["IP"]), int.Parse(config["port"], CultureInfo.InvariantCulture));
vsoptions.Listen(config["IPandPort"]);
options.Listen(config["IPandPort1"]); options.Listen(config["IPandPort2"]); options.Listen(config["IPandPort3"]);
config["IPsAndPorts"].Split(';').ForEach(endpoint => options.Listen(endpoint));
The text was updated successfully, but these errors were encountered: