Reputation: 11920
I have written an ASP.NET application that is based on .NET core 1.1. This application works as expected. Today, I just upgraded my server to dotnet-sdk-2.0.0-preview2-006497
and made necessary changes in the .csproj
file.
In my application's main method, I have the following code:
var host = new WebHostBuilder()
.UseKestrel(options => {
options.UseHttps("MyCert.pfx");
})
...
This code used to work fine under .net core 1.0 but gives an error under .net core 2.0.
KestrelServerOptions does not contain a definition for UseHttps and
the best extension method overload
ListenOptionsHttpsExtensions.UseHttps(ListenOptions, string) requires
a receiver of type ListenOptions
I am wondering how I can fix this. Can I just pass null
as a parameter? Regards.
Upvotes: 11
Views: 6112
Reputation: 13399
This is a breaking change, see this announcement, the important bit being:
There is no overload on .Listen() that allows you to configure an SSL cert without using an options lambda.
In other words you can only add HTTPS within or with some listen options. The simplest alternative would be:
var host = new WebHostBuilder()
.UseKestrel(options =>
options.Listen(IPAddress.Any, 443, listenOptions =>
listenOptions.UseHttps("MyCert.pfx")))
...
So you're saying listen on any assigned IP using port 443.
Upvotes: 20