I am working on a fabric application where I have configured HTTPS. It is throwing an exception though I have a valid installed certificate.
For me the problem was resolved by running:
If you want to work with an environment that is not Development, don't forget that user secrets are only added automatically when env is Development.
You can use the AddUserSecrets methods to resolve this :
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureAppConfiguration((hostingContext, builder) =>
{
var env = hostingContext.HostingEnvironment;
if (env.IsEnvironment("Local"))
{
builder.AddUserSecrets<Startup>();
}
})
.UseStartup<Startup>();
});
see also : https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-3.1&tabs=windows#access-a-secret
I hope a separate answer is ok since I don't have the rep to comment. Here's the solution I found, which I didn't see mentioned anywhere else on SO or other sites. This is specific to the Windows certificate manager, not sure if other OSes run into similar issues.
dotnet dev-certs https
argumentsI tried various combinations of dotnet dev-certs https
with --trust
, --clean
--verbose
(which didn't seem to actually log any additional info), and --check
(which never found a certificate)
As suggested in other answers, I deleted all localhost certificates under Trusted Root Certification Authorities\Certificates in certmgr.msc
in conjunction with dotnet dev-certs https --clean
Eventually I realized that certmgr.msc
also showed a number of localhost certificates under Personal\Certificates, in addition to those under Trusted Root Certification Authorities\Certificates. It turned out that these all needed to be deleted.
Then running dotnet dev-certs https -t
a single time created and trusted a new development certificate.
I verified by debugging an ASP.NET Core App. Another way to verify is by running dotnet dev-certs https --check --verbose
I run this on my command prompt. btw I am using Window 10 dotnet dev-certs https dotnet dev-certs https -t
These instructions from this blog worked for me
I had a similar (but not exactly the same) problem.
With 2.1 you have to configure your certificate.
I do this now completely in appsettings.json.
You can find my posting here:
Configure self hosting Kestrel App with certificate for https (internet web server)
Only have a look to the solution...