I've created a WebAPI .Net 5 App which listens on an HTTPS port 8286. When I run it in Visual Studio everything is good.
Once I do "Publish" and try to run it on our Windows Server 2012 I get a "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. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'..."
I have an SSL certificate installed on the server. It works with IIS and with a .NET 4.8 WebAPI Self hosted OWIN app
Using netsh http show sslcert I can see the certificate is bound

Here is my CreateHostBuilder function:
public static IHostBuilder CreateHostBuilder(string[] args)
{
Console.WriteLine("USE URLS: https://*:8286/");
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("https://*:8286/");
});
}

Startup.cs. The article Configure endpoints for the ASP.NET Core Kestrel web server shows how to specify the certificate either through settings, by providing the path to thepfxfile and password, or in code, by loading and using anX509Certificate2instance