kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

默认TLS1.0,可以改成TLS1.2 #182

Open sln162 opened 3 years ago

sln162 commented 3 years ago

在WebSocket.NoSilverlight.cs的类中,查看定义为SslProtocols.Defaul,但SslProtocols.Defaul已经被标记为过时: https://docs.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca5397?view=vs-2019 经过测试,可以用以下字符串代替: (SslProtocols)192 | (SslProtocols)768 | (SslProtocols)3072 尝试过使用SslProtocols.Tls12,但如果用户电脑只安装了.net4.0,例如win7,并没有安装更高版本的.net 4.5/4.7之类的,会出现错误,所以直接用 (SslProtocols)192 | (SslProtocols)768 | (SslProtocols)3072,就不会有问题,默认也用Tls1.2连接。

经过在xp、win7、win10,测试,服务器抓取日志,一切正常。

allenhuangxj commented 3 years ago

hi, can you tell me what version do you Use? (SuperSocket.ClientEngine.dll and WebSocket4Net.dll) . Now i meet a problem that my .net winform(.net 4.0) program must run in xp, but when i use 4.0 correlation websocket4net lib connect wss on xp throw error: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) at SuperSocket.ClientEngine.SslStreamTcpSession.OnAuthenticated(IAsyncResult result) @kerryjiang @sln162

sln162 commented 3 years ago

@allenhuangxj I use the source code directly, download the latest source code from stale branches, and then embed it in the program.

Some of my users are XP systems, and I haven't encountered any problems in. Net4.0. But XP can only use tls1.0, and use des-cbc3-sha algorithm. Your server should support this suite as well

allenhuangxj commented 3 years ago

方便发一份你们那边可以在xp上正常跑的demo程序么? @sln162

sln162 commented 3 years ago

@allenhuangxj It has been integrated into the program, and there is no time to do the demo.

kerryjiang commented 2 weeks ago

Please try to use WebSocket4Net 1.0.0-beta.2. https://www.nuget.org/packages/WebSocket4Net/1.0.0-beta.2