问题描述
大家好,
有人知道VB.NET是否真正支持Tls12,如果是,我需要使用哪个版本的VB和.NET.
Does anyone know if Tls12 is actually supported on VB.NET and if so what version of VB, and .NET do I need to be using.
搜索文档似乎表明.NET 4.5支持TLS12,但是没有.NET的代码示例,并且有评论说该语言可能不受支持.
Searching the documentation appears to suggest TLS12 is supported in .NET 4.5 but there is no code example for .NET and there was a comment that the language might not be supported.
我有一个使用REST与服务器通信的程序,并且服务器最近已升级到Tls1.2,所以我只需要升级我的VB或.NET版本,还是需要用C#重写:( ?
I have a program which uses REST to talk to a server and the server has recently been upgraded to Tls1.2 so do I just need to upgrade my version of VB or .NET or do I need to rewrite in C# :( ?
谢谢
Melcus
推荐答案
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
但是,对于.Net 4.6或更高版本,您不必这样做,并且对于.Net 4.5以下的版本,它将不起作用.因此,您需要将程序编译为.Net 4.5,才能使代码与.Net 4.5一起使用.或将程序编译到.Net 4.6或更高版本,然后您将不会 应该需要代码.
However you do not have to do that for .Net 4.6 or above and it will not work for below .Net 4.5. So you will need to compile your program to .Net 4.5 for the code to work with .Net 4.5. Or compile your program to .Net 4.6 or above and then you would not need the code supposedly.
Also see TLS 1.2 and .NET Support: How to Avoid Connection Errors.
更新:显然,对于.Net 4.0,以下代码可能有效.
Update: For .Net 4.0 apparently the below code may work.
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072
这篇关于VB.NET和Tls12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!