是否可以在.NET 4.0框架上使用TLS1.2发送HttpWebRequest [英] Is that possible to send HttpWebRequest using TLS1.2 on .NET 4.0 framework
问题描述
我的应用程序连接到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.
我想对该问题进行一些研究,并看到发送 HttpWebRequest
在.NET 4.0框架上使用TLS 1.2可以正常工作
I want to do some research on that issue and see sending HttpWebRequest
using TLS 1.2 on .NET 4.0 framework works
如果没有,我可能需要创建一个 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版本。 c $ c>。在调用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!