SKIT偶尔The SSL connection could not be established的解决方案

1.修改默认的httpclient

public class UntrustedCertClientFactory : DefaultHttpClientFactory
{
public override HttpMessageHandler CreateMessageHandler() {
return new HttpClientHandler {
ServerCertificateCustomValidationCallback = (a, b, c, d) => true
};
}
}

FlurlHttp.Configure(settings => {
settings.HttpClientFactory = new UntrustedCertClientFactory();
});

2.懒人办法,直接忽略证书验证,web.config增加如下代码

<configuration>
  <system.net>
    <settings>
      <servicePointManager
          checkCertificateName="false"
          checkCertificateRevocationList="false"
      />
    </settings>
  </system.net>
</configuration>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注