Skip to content

Introduce an IServiceCollection extension method for enabling HTTPS configuration #49967

@amcasey

Description

@amcasey

Background and Motivation

#48956 raised the point that ListenOptions.UseHttps will be unusable in 8.0 for servers constructed without an IWebHostBuilder, since the extension method for registering IHttpsConfigurationService only applies to that type. If we'd prefer to avoid breaking such users, we could introduce a comparable extension method on IServiceCollection - that's all the IWebHostBuilder extension method does anyway.

Proposed API

namespace Microsoft.AspNetCore.Obscure;

public static class HttpsConfigurationServiceCollectionExtensions
{
+    public IServiceCollection UseKestrelHttpsConfiguration(this IServiceCollection serviceCollection);
}

Usage Examples

serviceCollection.UseKestrelHttpsConfiguration();

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 and IServiceCollection.UseKestrelHttpsConfiguration.

Metadata

Metadata

Assignees

Labels

api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions