weixin_39915505
2021-01-12 09:43[Bug] SSLAuthentication error when using TcpClient with TLS1.2 -> Mono.Security.Interface.TlsException
Description
I am using TcpClient with TLS1.2 and occasionally when trying to write or authenticate the stream I get the following SSLAuthentication error:
Mono.Security.Interface.TlsException: Unknown Secure Transport error `ClosedGraceful'. at Mono.AppleTls.AppleTlsContext.CheckStatusAndThrow (Mono.AppleTls.SslStatus status, Mono.AppleTls.SslStatus[] acceptable) [0x000c1] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System/Mono.AppleTls/AppleTlsContext.cs:123
I don't get the exception every time, it seems to happen randomly, especially on iOS 13 and I can get it when trying to: 1) authenticate the client 2) write to an already authenticated stream, (where IsAuthenticated returned true earlier!)
It says on Stackoverflow the issue can be resolved by switching from Apple to Mono TLS implementation but I can't as Mono seems to use an older version of TLS that is not PCI compliant as suggested here https://stackoverflow.com/questions/38528616/tls-exception-unknown-secure-transport-error-closed-graceful
Any help would be appreciated.
Steps to Reproduce
- Implement TcpClient SSL stream,
TcpClient tcpClient = new TcpClient();
tcpClient.ConnectAsync(host, port);
SslStream sslStream = new SslStream(tcpClient.GetStream());
- Authenticate using TLS1.2 (for PCI compliance)
SslProtocols sslProtocols = (SslProtocols)Enum.Parse(typeof(SslProtocols), "Tls12");
sslStream.AuthenticateAsClient(this.Host, null, sslProtocols, true);
-
Create loop to read from stream on new 'read' thread
-
Close TcpClient connections and reopen(repeat multiple times)
Expected Behavior
I get no SSL Authentication errors or if I do that I get them every time.
Actual Behavior
When Authenticating and writing to SSL stream I intermittently get SSL Authentication errors.
Basic Information
- Version with issue: v4.2.0.709249
- Last known good version: unknown
- IDE: Visual Studio 2017 Windows & Mac
- iOS: All - iOS 10>
- Android: All - Android 6>
该提问来源于开源项目:xamarin/Xamarin.Forms
- 点赞
- 回答
- 收藏
- 复制链接分享
6条回答
为你推荐
- C# socket如何清空接收缓存呢
- c语言
- 开发语言
- c#
- 2个回答
- EchoServer(Java)未将消息返回给客户端(golang)
- tcp
- java
- tcpclient
- tcpserver
- 1个回答
- 在打开的TCP套接字上使用JSON回复
- json
- 2个回答
- 关于java 实现socket的异步通信
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- 为什么NetworkStream 读数据的时候程序自动停止,也捕捉不到异常?
- tcp/ip
- 异常
- 2个回答