title: Kestrel: Invoke-WebRequest doesn't work while the URL works in browser?
body: <h2>Update:</h2>
  
  <p>The following error only occur when launching the application using Kestrel.</p>
  
  <p>I already added the following two lines for <code>Microsoft.AspNetCore.Authentication.Negotiate</code></p>
  
  <pre><code>// in public void ConfigureServices(IServiceCollection services)
  services.AddAuthentication(NegotiateDefaults.AuthenticationScheme).AddNegotiate();
  
  // in public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  app.UseAuthentication();
  </code></pre>
  
  <hr>
  
  <p>I created a new test Asp.Net core Web API project (with <strong>Windows authentication</strong>) using Visual Studio 2019. And run it in Visual studio and a browser popped up with json returns shown.</p>
  
  <p>Then I open a Powershell window and tested the url. It got the following error?</p>
  
  <pre><code>PS C:\&gt; Invoke-WebRequest https://localhost:5001/weatherforecast
  Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
  At line:1 char:1
  + Invoke-WebRequest https://localhost:5001/weatherforecast
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
  </code></pre>
  
  <p>I found the <code>ASP.NET Core HTTPS development certificate</code>.</p>
  
  <pre><code>PS C:\&gt; ls Cert:\CurrentUser\My | ? Subject -eq 'CN=localhost' | fl
  
  Subject      : CN=localhost
  Issuer       : CN=localhost
  Thumbprint   : 7A16573FF2DBA47695B8CA15916D445C9361F255
  FriendlyName : ASP.NET Core HTTPS development certificate
  NotBefore    : 12/6/2019 4:45:04 PM
  NotAfter     : 12/5/2020 4:45:04 PM
  Extensions   : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid,
                 System.Security.Cryptography.Oid...}
  </code></pre>
  
  <p>And it still got the error?</p>
  
  <pre><code>PS C:\&gt; Invoke-WebRequest https://localhost:5001/weatherforecast -CertificateThumbprint 7A16573FF2DBA47695B8CA15916D445C -UseDefaultCredentials
  9361F255
  Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
  At line:1 char:1
  + Invoke-WebRequest https://localhost:5001/weatherforecast -Certificate ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
  </code></pre>