dotnet核心中的PFX证书有问题。但仅在IIS中不是红est

时间:2019-05-09 10:23:49

标签: c# .net-core asp.net-core-webapi x509certificate

这是我在Kestrel中成功做到的方式: 1.在Startup.cs中:

var bytes = File.ReadAllBytes(certPath);
X509Certificate2 certificate = new X509Certificate2(bytes);
  1. 在httpclientfactory中:

    services.AddHttpClient(“ ClientName”),客户端=> {     client.BaseAddress = new Uri(Configuration.GetValue(“ BConfigurations:BaseAddress”)); } .ConfigurePrimaryHttpMessageHandler(()=>新的HttpClientHandler {     ClientCertificates = {证书},     ClientCertificateOptions = ClientCertificateOption.Manual });

但是当我在IIS上发布内部版本时,我遇到了以下异常:(这在Kestrel中从未发生过)

  

WindowsCryptographicException:指定的网络密码不是   正确的Internal.Cryptography.Pal.CertificatePal.FilterPFXStore

0 个答案:

没有答案