Self-signed certificate ERROR with Kestrel when dotnet core/vs code web api on a Mac

Viewed 1396

I am trying to follow this documentation in the section "Replace the default certificate from configuration" so that I can use a self signed certificate (due to Android emulator) for my Web APIs which I am developing in VS Code using dotnet core 3.1. I don't seem to be able to get the certificate I want. There are two in my Keystore: localhost (created by VS Code earlier on) and development (the one I created using openssl)

I have created the certificate and it is listed in the Keychain as "development". The documentation referenced above says that we can edit the appsettings.json or appsettings.Development.json (which seems like the better option) to include:

"Certificates": {
  "Default": {
    "Path": "<path to .pfx file>",
    "Password": "<certificate password>"
  }
}

and use this for a keystore:

"Default": {
  "Subject": "<subject; required>",
  "Store": "<cert store; required>",
  "Location": "<location; defaults to CurrentUser>",
  "AllowInvalid": "<true or false; defaults to false>"
}

I have seen some other references such as .NET Core Kestrel with SSL which was a great reference but for 2.0. It did have some specific values to help understand how to fill out the entries, but some of the parameters have changed (Source for example).

  "Certificates": {
    "HTTPS": {
      "Source": "Store",
      "StoreLocation": "CurrentUser",
      "StoreName": "My",
      "Subject": "CN=localhost",
      "AllowInvalid": true
    }
  }

I basically used this as a guide for the new parameters which I included as:

    "Kestrel": {
    "Certificates": {
      "Default": {
        "Subject": "CN=development",
        "Store": "My",
        "Location": "CurrentUser",
        "AllowInvalid": true
      }
    }
  }

I am getting an error: 'The requested certificate CN=development could not be found in CurrentUser/My with AllowInvalid setting: True.'

I have also tried:

    "Kestrel": {
    "Certificates": {
      "Default": {
        "Subject": "CN=localhost",
        "Store": "My",
        "Location": "CurrentUser",
        "AllowInvalid": true
      }
    }
  }
0 Answers
Related