当前位置:   article > 正文

.net framework 4.0未能创建 SSL/TLS 安全通道_(securityprotocoltype)3072 不起效果

(securityprotocoltype)3072 不起效果

我是测试环境的正常的,上生产之后出现的问题
主要就是这部分:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)3072;

 public static string HttpPost(string url, string data, string auth)
        {
            HttpWebResponse wr = null;
            string _resContent = "";
            try 
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)3072;// | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13 | SecurityProtocolType.SystemDefault;

                var request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                request.ContentType = "application/json;charset=UTF-8";
                request.Headers.Add("Authorization", auth);

                byte[] byteData = Encoding.UTF8.GetBytes(data);
                int length = byteData.Length;
                request.ContentLength = length;
                Stream writer = request.GetRequestStream();
                writer.Write(byteData, 0, length);
                writer.Close();
                wr = (HttpWebResponse)request.GetResponse();
                _resContent = new StreamReader(wr.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd();
                wr.Close();
            } catch (Exception exp) 
            {
                LogHelper.Info("httpPost接口::" + exp.Message);
            }
            return _resContent.ToString();
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

完美解决!
原文链接:.net framework 4.0未能创建 SSL/TLS 安全通道

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/961699
推荐阅读
相关标签
  

闽ICP备14008679号