ASP.NET Core application setup production SSL certificate

Viewed 10017

I can run just fine on my dev box, but not in prod.

I have an SSL cert installed on my server for my domain.

How do I tell my ASP.NET Core application which certificate to use? I assume I need to add something to let it know.

I ask because currently i'm getting:

Unable to start Kestrel. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.

Trying to get it going on IIS, without any luck so testing using Kestrel just clicking on it on my work machine vs the server.

1 Answers

How do I tell my ASP.NET Core application which certificate to use? I assume I need to add something to let it know.

As far as I know, we could host the application by using kestrel or IIS.

If you want to bind the certificate for the web application which will host by kestrel, I suggest you could try to configure the certificate by calling below method:

UseHttps(X509Certificate2 serverCertificate)

More details, you could refer to below codes(Program CreateHostBuilder method):

                webBuilder.UseKestrel(serverOptions =>
                {
                    serverOptions.Listen(IPAddress.Loopback, 5001,
                        listenOptions =>
                        {
                            listenOptions.UseHttps("testCert.pfx",
                                "testPassword");
                        });

                });

If you want to bind the certificate for the web application which will host by IIS, there is no need to modify the program.cs codes, you could directly set the SSL by using IIS management console.

More details ,you could refer to this article.

Related