问题描述
我的应用程序连接到 Experian 服务器,Experian 将很快停止支持 TLS 1.0 和 TLS 1.1.所有使用 HTTPS 的连接都必须使用 TLS 1.2 版.
My application connects to Experian server and Experian will soon stop supporting TLS 1.0 and TLS 1.1. All connectivity using HTTPS must use TLS Version 1.2.
我想对该问题进行一些研究,并查看在 .NET 4.0 框架上使用 TLS 1.2 发送 HttpWebRequest
的工作
I want to do some research on that issue and see sending HttpWebRequest
using TLS 1.2 on .NET 4.0 framework works
如果没有,我可能需要在 .NET 4.5 上创建一个 webservice
并调用它的方法,如果有,我不需要任何东西.
If it does not, I will probably need to create a webservice
on .NET 4.5 and call its methods, if it does, I do not have to anything.
有没有人遇到过这个问题?
Has anyone already faced with that issue?
推荐答案
是的,它支持它,但您必须在 ServicePointManager
上明确设置 TLS 版本.只需在调用 Experian 之前随时运行此代码(在同一个应用程序域中):
Yes, it supports it but you must explicitly set the TLS version on the ServicePointManager
. Just have this code run anytime (in same app domain) before you make the call to Experian:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
更新
请参阅@iignatov 的答案,了解您必须为框架 v4.0 做些什么.我的代码适用于 4.5+
Update
see @iignatov 's answer for what you must do for framework v4.0. My code works with 4.5+
这篇关于是否可以在 .NET 4.0 框架上使用 TLS1.2 发送 HttpWebRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!