Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core Development Certificates - error exporting the HTTPS developer certificate

I installed Visual Studio 2022 on my laptop, which is a Windows 11 Home Edition. I created a new Angular and ASP.NET Core web application, using all the defaults. When Visual Studio was creating the solution, and again every time I try to run it using the F5 key, I get this error, in a command window:

First command: > [email protected] prestart

Second command: > node aspnetcore-https

Error:

There was an error exporting the HTTPS developer certificate to a file.

This is a fresh install of Visual Studio 2022, and the solution was created using all the defaults, which works perfectly on my Windows 10 PC. It happens even when I run VS as Administrator.

I have tried running these commands:

dotnet dev-certs https --clean

dotnet dev-certs https --trust

But that did not help.

Then I tried running this command:

dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p MyPassword

But it said that a valid HTTPS certificate was already present.

I ran this:

dotnet dev-certs https -v

And it found only one valid certificate.

I tried creating a second Angular and ASP.NET Core web application, but got the same error.

I don't know what else to try. Can anyone help?

like image 667
JRS Avatar asked Feb 17 '26 22:02

JRS


2 Answers

According to this link, there is a bug in new versions of .NET where the certificate folder is not automatically created.

The workaround is to add the following code in the aspnetcore-https.js file:

    const fs = require('fs');
    //...
    const baseFolder = 
    //...
    fs.mkdirSync(baseFolder, { recursive: true });

like image 87
Aaron Avatar answered Feb 20 '26 17:02

Aaron


I fixed the issue running Visual Studio as Administrator

like image 21
Nico Avatar answered Feb 20 '26 16:02

Nico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!