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

c# – 找不到System.Net.SecurityProtocolType.Tls12定义

发布时间:2020-12-15 19:47:44 所属栏目:百科 来源:网络整理
导读:我正在尝试将以下代码行添加到网站项目中的Global.asax文件中. System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; vs2012 IntelliSense显示存在Tls12定义.但构建是说定义不存在(参见屏幕截图). 我已经尝试将System
我正在尝试将以下代码行添加到网站项目中的Global.asax文件中.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

vs2012 IntelliSense显示存在Tls12定义.但构建是说定义不存在(参见屏幕截图).

screen shot

我已经尝试将System.Net.dll添加到项目的bin文件夹中,但构建仍然失败.知道我怎么能解决这个问题?

解决方法

仅在Framework 4.0上缺少SecurityProtocolType.Tls11和SecurityProtocolType.Tls12枚举值.

SecurityProtocolType数值:
SystemDefault(0)
Ssl3(48 – 0x30)
Tls(192 – 0xC0)
框架4.0中缺少Tls11(768 – 0x300)
Framework 4.0上缺少Tls12(3072 – 0xC00)

在Framework 4.0上,如果要允许TLS 1.0,1.1和1.2,只需替换:

SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12

通过:

(SecurityProtocolType)(0xc0 | 0x300 | 0xc00)

(编辑:李大同)

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

    推荐文章
      热点阅读