首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何清除客户端.Net SSL会话缓存

清除客户端.Net SSL会话缓存的方法如下:

  1. 在客户端的代码中,使用以下代码清除SSL会话缓存:
代码语言:csharp
复制
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; };
  1. 如果使用的是HttpClient类发送请求,可以使用以下代码清除SSL会话缓存:
代码语言:csharp
复制
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

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

Https详解+wireshark抓包演示

在说HTTPS之前先说说什么是HTTP,HTTP就是我们平时浏览网页时候使用的一种协议。HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HTTP协议传输隐私信息非常不安全。为了保证这些隐私数据能加密传输,于是网景公司设计了SSL(Secure Sockets Layer)协议用于对HTTP协议传输的数据进行加密,从而就诞生了HTTPS。SSL目前的版本是3.0,被IETF(Internet Engineering Task Force)定义在RFC 6101中,之后IETF对SSL 3.0进行了升级,于是出现了TLS(Transport Layer Security) 1.0,定义在RFC 2246。实际上我们现在的HTTPS都是用的TLS协议,但是由于SSL出现的时间比较早,并且依旧被现在浏览器所支持,因此SSL依然是HTTPS的代名词,但无论是TLS还是SSL都是上个世纪的事情,SSL最后一个版本是3.0,今后TLS将会继承SSL优良血统继续为我们进行加密服务。目前TLS的版本是1.2。

05
  • 浏览器页面呈现过程

    首先浏览器将输入的链接进行DNS解析,也就是将域名转换为IP地址的过程,得到了服务器具体的IP地址,才可以进行TCP链接以及数据的传输。 具体DNS解析的过程,浏览器首先检查自身的DNS缓存是否对于此域名有IP地址,chrome对于域名解析的缓存时间为60s,可以通过地址栏输入chrome://net-internals/#dns清除DNS缓存。若浏览器解析缓存未命中,则到操作系统中hosts文件检查域名与IP对应关系。若hosts文件未命中,则向本地域名服务器请求解析,本地域名服务器一般是运营商ISP提供的,一般是通过53端口发送UDP报文请求服务器解析DNS。若本地服务器解析未命中则会有两种解析方案:迭代解析与递归解析,一般来说,主机向本地域名服务器的查询一般都是采用递归查询,本地域名服务器向根域名服务器的查询通常是采用迭代查询,依次向根域名服务器、顶级域名服务器、主域名服务器等一级一级查询查询直到查询到IP地址。

    02
    领券