Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found
Asked Answered
D

29

256

I am working on a fabric application where I have configured HTTPS. It is throwing an exception though I have a valid installed certificate.

Dissertation answered 14/11, 2018 at 12:40 Comment(0)
M
491

These instructions from this blog worked for me

  1. dotnet dev-certs https --clean
  2. dotnet dev-certs https --trust
  3. Restart VS
Marabou answered 13/5, 2019 at 12:31 Comment(14)
if this fails (like it did in my case the check out @Stephen's answer ( https://mcmap.net/q/109512/-unable-to-configure-https-endpoint-no-server-certificate-was-specified-and-the-default-developer-certificate-could-not-be-found ) - that worked for me.Steapsin
Restarting VS was necessary for me in addition to these stepsInnerdirected
@AndrewBullock Updated to include that step, thanks.Marabou
Followed this but still had issues - then did what @hikarikuen suggested (https://mcmap.net/q/109512/-unable-to-configure-https-endpoint-no-server-certificate-was-specified-and-the-default-developer-certificate-could-not-be-found) - cleared the localhost personal certificates from the Windows Cert store, and then re-ran above command and everything worked.Attitude
Works like a charm! In windows is necessary to use the command prompt as AdministratorTholos
The same worked for me on Windows 11 and Rider. Got about five old certificated which were cleaned out and then with a new one it worked nicely.Mosquito
A CD C:\Program Files\dotnet helped meRancid
Just used the developer prompt (Tools > Command Line > Developer Command Prompt) and didn't even need to restart VS.Pareira
Used the Developer PowerShell in Visual Studio 17.2.5 and entered the 2 dotnet commands. No need to restart VS, it immediately works.Poor
This worked on Windows 11 and Visual Studio Code 2022.Sodden
Worked for me as well. didn't used Run as AdministratorIsotone
I also had to restart Chrome for it to workWollis
The waynethompson.com.au website says to me Error 403 - This web app is stopped.. Hopefully it is available in the wayback website.Witchcraft
worked like charm on ubuntu 22.04 on my vscode, thanks.Gloss
J
87

Solution

(for Windows, not sure if there's an equivalent issue/solution for other OSs)

In a command prompt or Powershell terminal:

  • Run certmgr.msc and delete all localhost certificates under both Personal\Certificates and Trusted Root Certification Authorities\Certificates.
  • Then run dotnet dev-certs https -t a single time to create and trust a new development certificate.
  • Verify by running dotnet dev-certs https --check --verbose, or just try debugging your ASP.NET app again.

You may also need to run dotnet dev-certs https --clean before creating the new certificate.

Judo answered 10/11, 2020 at 20:32 Comment(4)
Thanks for this. For my I needed to go and delete all of the "localhost" certs in certmgr.msc -> Personal\Certficates. I had tried all the other "things", and it didn't work until I did this.Milkfish
+1. There were a lot of junk localhost certificates under Personal\Certificates, even after running clean. Thank you.Polychromatic
Cleaning the certificates under the certificate manager was also required in my case. May you please rewrite your answer to first provide the resolution steps? In its current form it is likely there are people who go away before reaching the actual solution. (I could edit your answer for doing so, but it may be too much of a change to be done by anyone but the author.)Escolar
Thanks, the only solution working very for .NET 7 but to do this correctly, after your steps you should close IIS and restart Visual StudioBallistic
C
77

I am on OSX and dotnet dev-certs https --clean and sudo dotnet dev-certs https --clean were not working for me. Finally I was able to fix it with the following steps.

  1. Go into Keychain Access
  2. Unlock System Keychain
  3. Delete the localhost certificate
  4. Run dotnet dev-certs https -t

You should now be able to run without the error.

Edit:

If, after following the above answer, you do run into an error that reads There was an error saving the HTTPS developer certificate... check out this answer https://mcmap.net/q/111414/-cannot-create-developer-certificate-on-mac

Crusade answered 1/8, 2019 at 2:54 Comment(6)
next time just run as sudoer, dotnet ev-certs https --clean ;) also, trust your certs, they usually only complain for a reason.Berfield
@Berfield I did run as sudo and it still didn't work. I had to manually delete it from the Keychain to fix the issue.Crusade
You're a live saver dude.Gosser
This solution worked for me on OS X 10.14.6 with .NET Core 2.1(.301)Steapsin
This solution worked for me too on macOS Monterey 12.1 M1Snuffy
basically the problem is certificate that are generated using old passwords will not work when the user changes the password, therefore when you delete these old localhost certificates and run the above command it will save it using new password and it will workDevland
F
27

For me the problem was resolved by running:

  1. dotnet dev-certs https --clean
  2. dotnet dev-certs https --verbose

enter image description here

Farron answered 3/8, 2019 at 15:15 Comment(1)
The second command reported an error Unix LocalMachine X509Store is limited to the Root and CertificateAuthority stores. But completed successfully and fixed this issue.Sansbury
S
12

I had this issue on my Windows 10 system using visual studio. The problem seemed to be that the command used in the GUI to clear the local certs for HTTPS was failing with an error message that I can no longer reproduce.

The solution for me was to open the certmgr for the current windows account and to delete all of the personal localhost certs. There was ~20 certs there for me because I've tried re-creating them many times. After deleting all of those certs I ran my .Net core HTTPS API once more and everything worked!

In summary, open your certmgr for your current user and clear all personal/localhost certs.

Swetiana answered 22/7, 2019 at 13:44 Comment(1)
this worked for me after the other answers didn't. Cleared two sets of localhosts under Personal and Trusted Root Certs.Neuropath
H
10

For me deleting the files under file:\\%APPDATA%\Microsoft\SystemCertificates\My\Certificates and run in cmd dotnet dev-certs https -t solved my issue.

Hulda answered 2/9, 2021 at 1:51 Comment(1)
Seems like certmgr.msc failed to delete these files so deleting them manually solved the problemBurschenschaft
I
8

If you are visiting this page and if you are unfortunate like me who tried every single solution/approach mentioned on this page but nothing worked, then you may like to know what I did and solved my problem.

I was getting this error from my ASP.NET Core web application no matter how many times I deleted the localhost certificates.

enter image description here

Then, I created a self-signed certificate using Powershell with this command. [I copied this PowerShell snippet from somewhere on the internet. Cannot remember the source.] First, make sure that you have a writable location on your computer at C:\temp\. (You can use any other path as long as it can be read by your web app)

  $cert = New-SelfSignedCertificate -DnsName mydemowebapp.net -CertStoreLocation cert:\LocalMachine\My
  $pwd = ConvertTo-SecureString -String "MyPassword" -Force -AsPlainText
  Export-PfxCertificate -Cert $cert -FilePath C:\temp\cert.pfx -Password $pwd

Then, in my appsertings.Development.json, I added this entry.

  "Kestrel": {
    "EndPoints": {
      "Https": {
        "Url": "https://localhost:5000",
        "Certificate": {
          "Path": "C:\\temp\\cert.pfx",
          "Password": "MyPassword",
          "AllowInvalid": "true"
        }
      }
    }
  }

Ran the application, boom! problem solved. I used the same URL https://localhost:5000 as I found in my LaunceSettings.

enter image description here

I hate a solution like this, but at least I could continue my development with such a solution. I do not know what really happened recently that I had to face this issue. Was that a windows update? or something else? I don't know. I did not face this issue before, until recently. And yes, I remembered to run the Website in Kestrel rather than IIS.

Irrationality answered 7/2, 2022 at 22:31 Comment(2)
I am getting an error can't find '/app/C:\Temp\cert.pfx' :(Allard
Nice. I was on day two of a POC run, and this was the only thing that worked. However, I put it in my appsettings.json. I think this is also a nice solution because it paves the way for what one might have to do in a production situation. Worried about a security breach because you put a password in the appsettings.json? You can also put this in code, opening up options for getting a password in there. learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/…Pyne
A
6

In windows, dotnet dev-certs https --clean doesn't work for me, I have to delete these localhost certs manually.

  1. Open certmgr.msc
  2. Delete all localhost certs under 'Trusted Root Certification Authorities/Certificates'
  3. Run dotnet dev-certs https -t
Amandy answered 11/7, 2020 at 5:2 Comment(0)
B
6

I'm on a Mac (macOS 12.6.7) trying to run a ASP.NET Core website project in VS Code, and none of the above answers worked fully for me. Only almost.

How I made it work. Run the following commands in the terminal:

  • Clean the ASP.NET Core project: dotnet clean
  • Clear existing certificate: dotnet dev-certs https --clean
  • Create a fresh certificate: dotnet dev-certs https --trust

Now I was able to run the project with dotnet run and reloading the browser.

PS: If you're lazy, you can also chain the commands like this: dotnet clean && dotnet dev-certs https --clean && dotnet dev-certs https --trust

Bumf answered 20/7, 2023 at 0:30 Comment(0)
W
4

Open RUN , then type mmc.exe, then

enter image description here

enter image description here

double click certificate

enter image description here

Delete localhost cert in both folders

enter image description here

then open your powershell

dotnet dev-certs https --clean
dotnet dev-certs https 
dotnet dev-certs https --trust
Walkup answered 29/10, 2021 at 13:8 Comment(1)
Couldn't figure out why the localhost cert wasn't showing for me, then this answer solved it. Be sure to select my user when double clicking the certificates to add for snap-in. Thank you.Martyrdom
B
3

Generate a new certificate:

$ dotnet dev-certs https --trust
The HTTPS developer certificate was generated successfully.
Biofeedback answered 14/3, 2022 at 16:16 Comment(2)
Simple. Elegant. Quick AnswerDisorder
That did it for me too!Incorporation
B
2

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...

Bret answered 22/11, 2018 at 16:55 Comment(0)
W
2

If you're running your application locally using docker-compose, you may need to execute following commands:

  • dotnet dev-certs https --clean
  • dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p { password here }
  • dotnet dev-certs https --trust

Then add the following lines to your docker-compose.yml:

environment:
  - ASPNETCORE_Kestrel__Certificates__Default__Password=password
  - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
  - ~/.aspnet/https:/https:ro

More details see https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-6.0

Winnick answered 20/8, 2022 at 13:19 Comment(1)
question is not related to docker.Exergue
S
2

I was running into a similar issue, it has something to do with the certificate having the same name as the project. By deleting the .key and .pem files in the %appdata%/ASP.NET/https folder that correspond to your project, it will fix your issue, running the app after this automatically remade the certificates for me. If running the app after deleting those files doesn't work try

dotnet dev-certs https --clean

then

dotnet dev-certs https --trust

Here, this article also has this information. link to article

Stated answered 31/5, 2023 at 17:51 Comment(0)
C
1

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://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-3.1&tabs=windows#access-a-secret

Calvillo answered 20/1, 2020 at 16:38 Comment(1)
No need to create local variable, you can write check condition inlineBackbencher
B
1
  1. dotnet tool uninstall --global dotnet-dev-certs --version (required version)
  2. dotnet tool install --global dotnet-dev-certs
  3. dotnet dev-certs https --trust

For more details visit the GitHub issue page here also the official documentation Here

Backtrack answered 15/12, 2020 at 4:55 Comment(0)
A
1

If dotnet dev-certs https --clean not working.

  1. Open Run and open mmc.exe
  2. Inside MMC from File menu click on Add/Remove Snap-in.
  3. In the add/remove snap-in window, find certificates in available snap-ins and add it to the selected
  4. Pick User account
  5. In the console root -> Certificates Current User -> Personal click on Certificates
  6. You will see the list of issued and installed certificates for the current user. DON’T remove or change any certificates you don’t know, only remove certificates related to self-sign localhost ASP.NET Core.
Amitie answered 26/5, 2021 at 19:10 Comment(0)
N
1

I had the same issue, but none of the answers here helped. I figured out that I was missing line in configuration which caused it. (I was running asp.net through docker compose) The missing line was: ASPNETCORE_URLS=https://+:443;http://+:80 in docker-compose file:

version: '3.4'

services:
  webapplication1:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
    ports:
      - "80"
      - "443"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
Nainsook answered 12/10, 2023 at 11:50 Comment(0)
L
0

I had the same issues and cleaning -> then installing certs helped me (another answer here). You also may issue a certificate as like for production server. Quite helpful to know.

Lapoint answered 13/5, 2019 at 12:40 Comment(0)
S
0

Not sure if this will help anybody else but I had exactly this issue on my Mac. I have the project in Dropbox and so it is shared across machines, on the '2nd' machine I had to go in and manually delete the 'obj' and 'bin' folders, then re-run the application and it all worked

Sacco answered 4/9, 2019 at 10:42 Comment(0)
S
0

I was having the same issue. The problem was that the project was with .net 4.6.1 and not .net core .

Stesha answered 20/4, 2020 at 12:16 Comment(0)
P
0

I run this on my command prompt. btw I am using Window 10 dotnet dev-certs https dotnet dev-certs https -t

Pulchritudinous answered 18/8, 2020 at 20:25 Comment(1)
Please careful after using these command make sure you restart visual studioPulchritudinous
B
0

I ran into this problem and my solution was to restart. When I did and then reopened Visual Studio 2019, it asked me to accept a new SSL certificate. After that, I was able to run my program.

Burstone answered 28/4, 2021 at 17:39 Comment(0)
J
0

One more detail - If you generally log in as a normal (non-admin) user, do NOT run the "dotnet dev-certs https" commands from an admin command prompt if you have a separate admin-level identity. Run them in a normal command prompt under your normal login. Ask me how I know. :-P

If you run these commands from an elevated command prompt (using a distinctly separate admin identity) you will experience the following:

  • "dotnet dev-certs https --trust" will work just fine
  • "dotnet dev-certs https --check --verbose" will tell you that everything is fine
  • VS Code will continue to spit out the "Unable to configure HTTPS endpoint ..." error when you try to start the debugger
  • You will continue to get "Certificate Not Trusted" warnings from your browser.

If you see these issues, run the "dotnet dev-certs https" commands from a normal command prompt. Fixed it for me. Hope this helps someone without spending the time that I did on this!

Jimerson answered 8/5, 2021 at 0:21 Comment(0)
T
0

When I tried everything, I still got ERR_SSL_VERSION_OR_CIPHER_MISMATCH.

You can try to delete bin and obj directories of all projects, then run dotnet restore.

Working for me.

Treva answered 20/12, 2022 at 12:58 Comment(1)
Isn't that what @Kevin Jones' answer already suggests?Uriiah
M
0

I tried everything listed here. I'm using macOS. my cert was trusted and i ended up deleting it and getting back multiple times with the above commands and it still wasn't working when i did a docker-compose up through my terminal.

However using the play button in visual studio for mac, that worked Instantly.

Moult answered 5/3, 2023 at 0:1 Comment(0)
H
0

If you're using node, and your localhost certificate expired, your .key and .pem files will no longer be valid. So you need to remove & regenerate them. In you have "prestart": "node aspnetcore-https" in your package.json, this will automatically regenerate them for you, using the new (valid) localhost certificate (after running the dotnet dev-certs https --trust command)

Hogarth answered 16/2 at 7:21 Comment(0)
D
-1

If you wanted to get rid of this issue,then in launchsettings.json change "useSSL": false

Dorset answered 27/8, 2022 at 13:13 Comment(1)
Like seriously do you want to pretend the world is all secure out there ? This may work for a school project to teach elements, or temporarily for debugging purpose. But certainly is not a solution.Brandybrandyn
T
-2

I commented following line in 'Startup.cs' file, and it worked for me.

app.UseHttpsRedirection();
Timepleaser answered 22/3, 2021 at 11:30 Comment(2)
Comments are not fixesDeenadeenya
commenting out this could help to get unblocked, in my project this was not the issue, manually had to update properties/launchSettings.json, remove from there the https url "applicationUrl": "localhost:5094", I know this is not the fix but while developing It is valid to use http onlyRainfall

© 2022 - 2024 — McMap. All rights reserved.