清除客户端.Net SSL会话缓存的方法如下:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.DefaultConnectionLimit = 9999;
System.Net.ServicePointManager.UseNagleAlgorithm = false;
System.Net.ServicePointManager.CheckCertificateRevocationList = false;
System.Net.ServicePointManager.EnableDnsRoundRobin = true;
System.Net.ServicePointManager.DnsRefreshTimeout = 0;
System.Net.ServicePointManager.MaxServicePointIdleTime = 0;
System.Net.ServicePointManager.MaxServicePoints = 9999;
System.Net.ServicePointManager.ReusePort = true;
System.Net.ServicePointManager.UseNagleAlgorithm = false;
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.DefaultConnectionLimit = 9999;
System.Net.ServicePointManager.UseNagleAlgorithm = false;
System.Net.ServicePointManager.CheckCertificateRevocationList = false;
System.Net.ServicePointManager.EnableDnsRoundRobin = true;
System.Net.ServicePointManager.DnsRefreshTimeout = 0;
System.Net.ServicePointManager.MaxServicePointIdleTime = 0;
System.Net.ServicePointManager.MaxServicePoints = 9999;
System.Net.ServicePointManager.ReusePort = true;
System.Net.ServicePointManager.UseNagleAlgorithm = false;
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
using (var httpClientHandler = new HttpClientHandler())
{
httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
httpClientHandler.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
// 发送请求
}
}
请注意,以上代码中的SSL协议类型和其他设置可能需要根据具体情况进行调整。
推荐的腾讯云相关产品:腾讯云SSL证书服务(https://cloud.tencent.com/product/ssl)