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>

另外的猜想:服务器TLS协议版本的问题,因为微信已经不支持1.1和1.0版本,服务器禁用该版本试试(本人测试这个方法管用)

发表回复

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