Ignore bad certificate - .NET CORE

前端 未结 4 403
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 02:44

I\'m writing a .NET Core app to poll a remote server and transfer data as it appears. This is working perfectly in PHP because the PHP is ignoring the certificate (which is

4条回答
  •  一整个雨季
    2020-12-30 03:43

    Just to add another variation, you could add in your thumbprint and check it in the callback to make things a bit more secure such as:

    if (!string.IsNullOrEmpty(adminConfiguration.DevIdentityServerCertThumbprint))
    {
       options.BackchannelHttpHandler = new HttpClientHandler
       {
          ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => certificate.Thumbprint.Equals(adminConfiguration.DevIdentityServerCertThumbprint, StringComparison.InvariantCultureIgnoreCase)
       };
    }
    

    adminConfiguration.DevIdentityServerCertThumbprint is the configuration that you would set with your self signed cert's thumbrint.

提交回复
热议问题