未调用ASP.NET Core自定义客户端证书验证

时间:2020-10-23 16:51:40

标签: .net asp.net-core asp.net-core-2.1 client-certificates

我正在尝试为集成测试设置实施自定义客户端证书验证。我正在像这样使用ASP.NET Core 2.1.latest和Kestrel:

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;
}

但是,从未调用过我的函数RememberClientCertificate。不管我是否发送客户证书。

我在做什么错了?

0 个答案:

没有答案