csharpfritz / csharp_with_csharpfritz

Show notes, slides, and samples from the CSharp with CSharpFritz show
MIT License
662 stars 215 forks source link

SSL Error Message for a New MVC App with app.UseHttpsRedirection(); #115

Open nakigoe opened 2 years ago

nakigoe commented 2 years ago

When I'm trying to run a new MVC app from the localhost, I receive the following error both in Edge and in Chrome:

The connection for this site is not secure, localhost uses an unsupported protocol. ERR_SSL_VERSION_OR_CIPHER_MISMATCH Unsupported protocol The client and server don't support a common SSL protocol version or cipher suite.

The two standard Microsoft commands have no effect, the certificate is created but the problem persists.

dotnet dev-certs https --clean

dotnet dev-certs https --trust

Outdated certificates are not present in my C:/Users/…/AppData/Roaming/ folder. So it looks like that's not the issue with old certificates. The ASP.NET folder exists in the C:/Users/…/AppData/Local/ASP.NET, deleting files from it has no effect either.

When I comment out the app.UseHttpsRedirection(); , the app starts, but in the http mode only

my LaunchSettings.json:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:62148",
      "sslPort": 44378
    }
  },
  "profiles": {
    "Angel": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "http://localhost:5555;https://localhost:7777",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Release"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Release"
      },
      "Host": {
        "LocalHttpPort": 7071,
        "CORS": "*",
        "CORSCredentials": false
      }
    },
    "Host": {
      "LocalHttpPort": 7071,
      "CORS": "*",
      "CORSCredentials": false
    }
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*",
    "CORSCredentials": false
  }
}

I had the same issue with Blazor WebAssembly, but I resolved it somehow, probably by tinkering with Win+R and running mmc and adding certificates manually. I don't know whether it helped or something else happened. This time running mmc and installing the certificates manually seems to have no effect. I followed the instructions from this Microsoft page: https://docs.microsoft.com/en-us/troubleshoot/developer/visualstudio/installation/warnings-untrusted-certificate