title: Self-signed certificate ERROR with Kestrel when dotnet core/vs code web api on a Mac
body: <p>I am trying to follow <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1" rel="nofollow noreferrer">this</a> documentation in the section &quot;Replace the default certificate from configuration&quot; 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)</p>
  <p>I have created the certificate and it is listed in the Keychain as &quot;development&quot;. The documentation referenced above says that we can edit the appsettings.json or appsettings.Development.json (which seems like the better option) to include:</p>
  <pre><code>&quot;Certificates&quot;: {
    &quot;Default&quot;: {
      &quot;Path&quot;: &quot;&lt;path to .pfx file&gt;&quot;,
      &quot;Password&quot;: &quot;&lt;certificate password&gt;&quot;
    }
  }
  </code></pre>
  <p>and use this for a keystore:</p>
  <pre><code>&quot;Default&quot;: {
    &quot;Subject&quot;: &quot;&lt;subject; required&gt;&quot;,
    &quot;Store&quot;: &quot;&lt;cert store; required&gt;&quot;,
    &quot;Location&quot;: &quot;&lt;location; defaults to CurrentUser&gt;&quot;,
    &quot;AllowInvalid&quot;: &quot;&lt;true or false; defaults to false&gt;&quot;
  }
  </code></pre>
  <p>I have seen some other references such as <a href="http://www.philipermish.com/blog/how-to-use-ssl-with-dotnet-core-and-kestrel/" rel="nofollow noreferrer">.NET Core Kestrel with SSL</a> 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).</p>
  <pre><code>  &quot;Certificates&quot;: {
      &quot;HTTPS&quot;: {
        &quot;Source&quot;: &quot;Store&quot;,
        &quot;StoreLocation&quot;: &quot;CurrentUser&quot;,
        &quot;StoreName&quot;: &quot;My&quot;,
        &quot;Subject&quot;: &quot;CN=localhost&quot;,
        &quot;AllowInvalid&quot;: true
      }
    }
  </code></pre>
  <p>I basically used this as a guide for the new parameters which I included as:</p>
  <pre><code>    &quot;Kestrel&quot;: {
      &quot;Certificates&quot;: {
        &quot;Default&quot;: {
          &quot;Subject&quot;: &quot;CN=development&quot;,
          &quot;Store&quot;: &quot;My&quot;,
          &quot;Location&quot;: &quot;CurrentUser&quot;,
          &quot;AllowInvalid&quot;: true
        }
      }
    }
  </code></pre>
  <p>I am getting an error:
  'The requested certificate CN=development could not be found in CurrentUser/My with AllowInvalid setting: True.'</p>
  <p>I have also tried:</p>
  <pre><code>    &quot;Kestrel&quot;: {
      &quot;Certificates&quot;: {
        &quot;Default&quot;: {
          &quot;Subject&quot;: &quot;CN=localhost&quot;,
          &quot;Store&quot;: &quot;My&quot;,
          &quot;Location&quot;: &quot;CurrentUser&quot;,
          &quot;AllowInvalid&quot;: true
        }
      }
    }
  </code></pre>