加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 为ServicePointManager.SecurityProtocol设置每个请求值

发布时间:2020-12-15 17:46:07 所属栏目:百科 来源:网络整理
导读:参见英文答案 Set the SecurityProtocol (Ssl3 or TLS) on the .net HttpWebRequest per request6 在c#中,我可以为SSL3或TLS设置静态值,例如 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 要么: ServicePointManager.SecurityProtoco
参见英文答案 > Set the SecurityProtocol (Ssl3 or TLS) on the .net HttpWebRequest per request6
在c#中,我可以为SSL3或TLS设置静态值,例如
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

要么:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

但是(我相信)这将影响我应用程序中的所有将来的HttpWebRequest对象.

有没有办法为给定的HttpWebRequest或至少为给定的URI设置这个?

注意我已经看到这个:

Uri uri = new Uri(url);
ServicePoint sp = ServicePointManager.FindServicePoint(uri);

但是ServicePoint没有SecurityProtocol属性.

目前,我想我将必须在创建一个新的HttpWebRequest之前设置静态全局属性.

这不觉得正确,也意味着:

>我必须确保多个线程不是在同一时间这样做.
>我不知道这个设置是什么时候被使用的(即当我调用webRequest.GetResponse()来访问ServicePointManager.SecurityProtocol并绑定到该URI时)?

解决方法

实现这一点已经在这里被覆盖:

How to use SSL3 instead of TLS in a particular HttpWebRequest?

和这里:

Set the SecurityProtocol (Ssl3 or TLS) on the .net HttpWebRequest per request

确认我的恐惧有些用户似乎正在旋转一个单独的应用程序域来解决这个问题.我仍然认为一些线程锁定可能是可能的,如果它被定义在什么时候绑定到特定的Web请求对象的位置.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读