Skip to content

Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.Protocols is internal in Microsoft.AspNetCore v2.3.0 #61823

Closed
@nasrilg7

Description

@nasrilg7

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Microsoft.AspNetCore v2.2.0 Nuget Package was reported vulnerable, and an upgrade to Microsoft.AspNetCore v2.3.0 nuget package is required. After the upgrade, the Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.Protocols property is set to internal with a default value of HttpProtocols.Http1. Why is this property internal in v2.3.0 (source)? How can I set the supported protocols to HTTP/1.x and 2?
Please note that the official documentation is marking this as a public property Here

Expected Behavior

This property should be public, or the documentation should be up-to-date and provide alternatives to set the Protocol property.

Steps To Reproduce

  1. Reference Nuget Package Microsoft.AspNetCore v2.2.0, and Implement a simple Start() method to start a kestrel endpoint:
internal class Class1
{
    public void Start()
    {
        var builder =
            WebHost
                .CreateDefaultBuilder()
                .ConfigureServices(collection => {})
                .Configure(applicationBuilder => {});

        builder =
            builder.UseKestrel(
                kestrelServerOptions =>
                {
                    kestrelServerOptions
                        .ListenAnyIP(
                            5000,
                            listenOptions =>
                            {
                                listenOptions.UseHttps(
                                    adapterOpts =>
                                    {
                                        adapterOpts.SslProtocols = SslProtocols.Tls12;
                                    });

                                listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
                            });
                });

        IWebHost host = builder.Build();

        host.StartAsync().Wait(TimeSpan.FromSeconds(30));
    }
}
  1. Update the Nuget Package to Microsoft.AspNetCore v2.3.0, a build error will indicate that the Protocols Property is internal and cannot be set.

Exceptions (if any)

No response

.NET Version

.NET 8

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions