zl程序教程

您现在的位置是:首页 >  Javascript

当前栏目

c# HttpWebRequest 解决 请求HTTPS慢

2023-03-15 22:05:20 时间

其实就几行代码

if (strUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                request.Credentials = CredentialCache.DefaultCredentials;
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                request.ProtocolVersion = HttpVersion.Version11;

                ServicePointManager.CheckCertificateRevocationList = true;
                ServicePointManager.DefaultConnectionLimit = 100;
                ServicePointManager.Expect100Continue = false;
            }