-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Introduce an IServiceCollection extension method for enabling HTTPS configuration #49967
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
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
Obviously, the namespace should not actually be called "Obscure" - that's just there to make the point that it should probably require a special import. |
API Review Notes
|
Creating kestrel manually from the KestrelServer constructor is the only way to do this without IWebHostBuilder, right? I agree with @halter73, just make that constructor always work, no new API. |
Part of the problem is that But we probably should still use aspnetcore/src/Servers/Kestrel/Core/src/KestrelServer.cs Lines 33 to 39 in ca08b82
I think our best option is to obsolete KestrelServer and its constructor and point people to CreateSlimBuilder() instead. You also cannot use HTTP/3 or metrics if you use this constructor, so this is even more reason to obsolete it. @JamesNK Normally, I'd say go to whatever lengths are necessary to avoid breaking changes (which is why may never actually delete the deprecated KestrelServer constructor), but new API doesn't stop the break. The existing code to make UseHttps work with the public KestrelServer constructor already involves hacks like a custom If customers absolutely do not want to use CreateSlimBuilder(), they also have the option copy the service descriptors from UseKestrel using a custom IWebHostBuilder, and then resolve the IServer. It's still ugly and fragile (which is why we should deprecate KestrelServer), but less so than the custom IConfigureOptions, and it would have the upside of giving you things like HTTP/3 support if you want it. If we must add a new API to make adding Kestrel HTTPS services to an IServiceCollection more convenient without an IWebHostBuilder, hiding it in a non-extension static method might help prevent it from causing confusion since it's so rarely needed. I don't think we should add something specifically for just Kestrel's HTTPS-related services like UseKestrelHttpsConfiguration. It should just be AddKestrel (Required services + HTTPS + HTTP/3) and AddKestrelCore (Required services) to align with the "Use"-prefixed IWebHostBuilder counterparts. |
Yep.
Sorry, I didn't follow this.
We discussed this and I believe we could quite a bit of pushback from the community.
What's the workaround? Copy-paste the internal implementation type and register that?
I don't have an immediate sense of how feasible this is, but a bad workaround is qualitatively different from no workaround.
|
I've closed the underlying issue with an explanatory comment and multiple proposed workarounds. |
Background and Motivation
#48956 raised the point that
ListenOptions.UseHttps
will be unusable in 8.0 for servers constructed without anIWebHostBuilder
, since the extension method for registeringIHttpsConfigurationService
only applies to that type. If we'd prefer to avoid breaking such users, we could introduce a comparable extension method onIServiceCollection
- that's all theIWebHostBuilder
extension method does anyway.Proposed API
namespace Microsoft.AspNetCore.Obscure; public static class HttpsConfigurationServiceCollectionExtensions { + public IServiceCollection UseKestrelHttpsConfiguration(this IServiceCollection serviceCollection); }
Usage Examples
Alternative Designs
I suppose, hypothetically, we could expose more of the internal HTTPS configuration types directly and let consumers register them as they see fit, but that seems a lot more complicated and harder to maintain.
Risks
Users might be confused about the difference between
IWebHostBuilder.UseKestrelHttpsConfiguration
andIServiceCollection.UseKestrelHttpsConfiguration
.The text was updated successfully, but these errors were encountered: