ASP.NET Core custom client certificate validation not called

1.2k views Asked by At

I'm trying to implement custom client certificate validation for an integration test setup. I'm using ASP.NET Core 2.1.latest and Kestrel like so:

new WebHostBuilder()
  .UseKestrel(
    ok => ok.ConfigureHttpsDefaults(
      o =>
      {
        o.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
        o.ClientCertificateValidation = RememberClientCertificate;
      }))
  [..]
  .UseUrls("https://localhost:5051")

[..]

private static bool RememberClientCertificate (X509Certificate2 clientCertificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
  LastClientCertificate = clientCertificate;
  return true;
}

However, my function RememberClientCertificate is never ever called. Regardless of whether I'm sending a client certificate or not.

What am I doing wrong?

0

There are 0 answers