现在已经发现SSL 3容易受到POODLE攻击:
System.Net.WebRequest在连接到任何https Uri时使用哪些版本的SSL/TLS?
我使用WebRequest连接到多个第三方API.其中一个已经表示他们将阻止使用SSL 3的任何请求.但是WebRequest是.Net核心框架的一部分(使用4.5),因此它使用的版本并不明显.
我支持一个.NET站点(其中很多,很多,其他东西)与供应商系统的远程API进行通信.
我们想升级以支持TLS 1.2我们希望按照这个问题这样做:是否有TLS 1.2的.NET实现?
但是,一旦我做出改变,我该如何检查这是否真的有效.
理想情况下,我的一个供应商网站将开始仅使用TLS 1.2 ,然后我的测试可能就是"我们现在可以与该供应商交谈吗?" 但我们没有那个.我猜我可以用某种类型的数据包嗅探器做一些事情,但我不知道我究竟在寻找什么,也不知道如何设置嗅探器以可读的方式收集必要的数据.
或者:
要么
我使用以下代码并获得HttpRequestException
异常:
using (var handler = new HttpClientHandler())
{
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.SslProtocols = SslProtocols.Tls12;
handler.ClientCertificates.Add(new X509Certificate2(@"C:\certificates\cert.pfx"));
// I also tried to add another certificates that was provided to https access
// by administrators of the site, but it still doesn't work.
//handler.ClientCertificates.Add(new X509Certificate2(@"C:\certificates\cert.crt"));
//handler.ClientCertificates.Add(new X509Certificate2(@"C:\certificates\cert_ca.crt"));
using (var client = new HttpClient(handler))
{
var response = client.GetAsync("https://someurl.com/api.php?arg1=some&arg2=test").GetAwaiter().GetResult();
// ^ HttpRequestException: An error occurred while sending the request.
}
}
Run Code Online (Sandbox Code Playgroud)
例外:
WinHttpException: A security error occurred
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult() …
Run Code Online (Sandbox Code Playgroud) 我目前有一个使用.NET 3.5框架的Web应用程序,我想知道它是否与TLS 1.2兼容.我们的代码中没有在哪里指示TLS版本.这是一个遗留应用程序,并且重新编译现在不在桌面上.我没有找到关于您是否可以获得的信息,但我认为兼容性更依赖于操作系统版本.看起来最小值是2008 R2.目标是让paypal在7月1日正确沟通.
根据PCI,我们需要根据http://blog.securitymetrics.com/2015/04/pci-3-1-ssl-and-从2016年6月30日起停止使用SSL和TLS(在某些实施中为1.0和1.1). tls.html
我们在.Net 3.5上构建了一个客户端应用程序,它使用HttpWebRequest对象连接到Web服务.
根据MSDN SecurityProtocolType(https://msdn.microsoft.com/en-us/library/system.net.securityprotocoltype ( v= vs.110).aspx)仅支持.Net Framework 4上的Ssl3和Tls(1.0)或下面.仅在.Net Framework 4.5/4.6中支持Tls11和Tls12
这是否意味着在Cardholder数据环境中并且完全符合pci标准,我们需要将所有应用程序升级到.Net 4.5/4.6并且只允许Tls12 SecurityProtocolType使用HttpWebRequest连接到外部Web服务?
随着Paypal更新他们的响应,我需要在.NET 3.5框架上的现有应用程序中将安全协议TLS更新到v1.2.在现有代码中更新此更改所需的更改,我无法将应用程序更新到更新的框架.
我们的ASP.NET 2.0网站通过调用Authorize.Net的API来处理信用卡交易.授权已通知我们,在确定的日期,我们的客户必须使用TLS 1.2协议进行API调用.
Microsoft似乎表明这个10-22-16 KB文章中提供了一个解决方案:https://support.microsoft.com/en-us/help/3154517/support-for-tls-system-default-versions-included -in最.NET框架-2.0-SP2-ON-Windows的Vista的SP2和服务器-2008-SP2
...我们添加了SslProtocolsExtensions枚举,您可以将其用作设置TLS v1.2,TLS v1.1的选项,以及针对.NET Framework 2.0 SP2时ServicePointManager.SecurityProtocol属性的操作系统默认值.
请注意,尽管有本文的标题,但上述引用并未涉及Windows Vista SP2或Windows 2008 SP2操作系统,因为这些操作系统不支持TLS v1.1和1.2.
我已经通过以下步骤实现并测试了我对KB文章中指出的解决方案的理解:
不幸的是,在运行应用程序时,我在上面第3项中显示的代码行上遇到以下错误:
System.NotSupportedException:不支持请求的安全协议.
在这一点上,我很难过.我特别感谢有关如何推进此解决方案的任何见解,但我有兴趣了解您所知道的任何其他方法,以允许来自ASP.NET 2.0应用程序的API调用来使用TLS 1.2.(升级到更新版本的.NET框架是最后的选择.)
在此先感谢您的帮助!
我们使用对USB的Web API调用来检查地址信息.他们需要TLS 1.2并且交换机已经破坏了我们的页面.
<%
If ACTION="Verify" and ncSCountry="USA" and ncSState<>"PR" and ncSState<>"AA" and ncSState<>"AP" and ncSState<>"AE" then
Dim sXML
sXML = "<?xml version='1.0'?>"
sXML = sXML & "<AccessRequest xml:lang='en-US'>"
sXML = sXML & "<AccessLicenseNumber>XXXXXX</AccessLicenseNumber>"
sXML = sXML & "<UserId>XXXX</UserId>"
sXML = sXML & "<Password>XXXX</Password>"
sXML = sXML & "</AccessRequest>"
sXML = sXML & "<?xml version='1.0'?>"
sXML = sXML & "<AddressValidationRequest xml:lang='en-US'>"
sXML = sXML & "<Request>"
sXML = sXML & "<TransactionReference>"
sXML = sXML & "<CustomerContext /><XpciVersion>1.0001</XpciVersion>"
sXML = sXML …
Run Code Online (Sandbox Code Playgroud) 所以我试图在我的服务器上关闭TLS 1.0和1.1.当我关闭TLS 1.0时,我的应用程序中出现以下错误:
System.ServiceModel.Security.SecurityNegotiationException: The caller was not authenticated by the service. ---> System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed.
at System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target)
at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)
Run Code Online (Sandbox Code Playgroud)
启用TLS 1.0后一切正常.
现在,调用该服务的代码使用ServicePointManager
以下代码指定TLS 1.2 :ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
另一端的服务正在运行.Net 4.6.2,并没有指定使用的TLS协议ServicePointManager
,因此根据我的阅读,它将自动检测在此版本的.net框架中运行时需要哪个TLS协议.
有关绑定的WCF服务的Web.config如下
呼叫配置:
<basicHttpBinding>
<binding name="MyBinding" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00"/>
</basicHttpBinding>
<netTcpBinding>
<binding name="CrossDomainBinding">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</netTcpBinding>
<client>
<endpoint address="net.tcp://MyService.svc"
binding="netTcpBinding" bindingConfiguration="CrossDomainBinding" behaviorConfiguration="CrossDomainBehavior"
contract="MyContract" name="MyBinding">
<identity>
<certificate …
Run Code Online (Sandbox Code Playgroud) 我需要将JSON数据发布到TLS 1.2端点。我想在App.config中指定SecurityProtocol,而不是在源中进行硬编码,并且不想将计算机的注册表设置为禁用TLS 1.1。
如果未指定SecurityProtocol,则使用底层OS协议,但默认情况下它们似乎是最不安全的,而不是最安全的。因为我有从计算机运行的多种服务,所以不能将操作系统设置为仅使用TLS1.2,但是我仍然希望该特定客户端使用TLS 1.2,并且当TLS 1.3推出时,可以通过应用程序特定的配置对其进行修改。
这个问题解释了如何通过代码做到这一点:如何为WebClient类指定SSL协议
这个问题说明了如何通过整个计算机的注册表设置来做到这一点:是否存在TLS 1.2的.NET实现?
// this is what I want to avoid
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocol.Tls12;
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(request.GetRequestStream()))
{
sw.write(json);
}
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
using System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream()))
{
content = sr.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud)
我的客户端当前在App.config中没有任何内容,但这是我想要更改的内容。
我发现system.serviceModel里面有一个sslStreamSecurity元素,但是我相信这是针对ServiceReferences的,不是正常的HttpWebRequest。我相信它已包含在system.net下,但我找不到等效的文件。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="myBinding">
<sslStreamSecurity sslProtocls="Tls12">
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://myserver.com" binding="customBinding" bindingConfiguration="myBinding" name="myEndpoint" />
</client>
</system.ServiceModel>
Run Code Online (Sandbox Code Playgroud)
我很愿意使用HttpWebRequest / HttpWebResponse以外的其他方式,但希望远离安装第三方软件包。我开始寻找一条System.Net.Http.HttpClient
比HttpWebRequest更新的路径,但很快遇到了同样的问题。
最近我们的 PCI DSS 扫描失败,并要求我们禁用 TLS 1.0(并启用 TLS 1.1 或 1.2)。我在 Windows Server 2008 R2 盒子上找到了如何执行此操作的说明,但我们有一个使用 .NET 远程处理的旧应用程序(它是一个 .NET 2.0 windows 窗体应用程序/IIS 托管的 CSLA 1.5 数据门户),它没有t 与新设置进行通信。
我收到以下异常:
我尝试了客户端和服务器中 TLS 设置组合的各种配置,但均无济于事。例如:
我做了一些研究,发现.NET 4.5 框架支持 TLS 1.1 和 1.2,但尚不清楚这是否扩展到 .NET 远程处理。可以?
另外,我发现微软的建议是升级到 4.5.2。
也就是说,这个应用程序与 .NET 4.5.2 有很多依赖性和不兼容性,因此了解我是否确实通过升级朝着正确的方向前进,或者我是否应该疯狂地完全重写这个应用程序会很有帮助(我探索过的所有选项都需要对应用程序进行重大更改)。即使构建一个测试应用程序来尝试它也可能具有挑战性,因为我已经大约 10 年没有直接处理过 .NET 远程处理了。
所以,我的问题又是 - .NET 远程处理支持 TLS 1.1 还是 1.2?
还:
我有一个在 VB.net 中编码的应用程序,它具有这种访问 Webservice 的方法,我遇到了这个错误,在搜索修复程序后我仍然没有运气。
错误:请求被中止:无法创建 SSL/TLS 安全通道。
'ServicePointManager.Expect100Continue = False
'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Dim ErrMsg As String = String.Empty
Try
Dim response As WebResponse = request.GetResponse()
Using responseStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(responseStream, Encoding.UTF8)
Return reader.ReadToEnd()
End Using
Catch ex As WebException
ErrMsg = ex.Message.ToString
MsgBox(ErrMsg)
Dim errorResponse As WebResponse = ex.Response
Using responseStream As Stream = errorResponse.GetResponseStream()
Dim reader As New StreamReader(responseStream, Encoding.GetEncoding("utf-8"))
' log errorText
Dim …
Run Code Online (Sandbox Code Playgroud) .net ×6
c# ×6
asp.net ×5
tls1.2 ×5
ssl ×3
.net-4.5 ×1
.net-core ×1
app-config ×1
asp.net-2.0 ×1
asp.net-core ×1
csla ×1
fiddler ×1
iis-7.5 ×1
paypal ×1
vb.net ×1
wcf ×1
webclient ×1
webrequest ×1
wireshark ×1