Anonymous
Sslstream Read возвращает 0 [закрыто]
Сообщение
Anonymous » 17 фев 2025, 17:52
У меня есть странная проблема с SSLStream в моем приложении. закрыт)
То же приложение, которое работает на той же ОС (Windows 11 23H2) в той же сети, работает правильно. тот же сервер.
Есть идеи? p>
Authenticated: true
protocol: tls12
cyphersuite: tls_ecdhe_rsa_with_aes_128_cbc_sha256
LeaveInnerStreamoPen: false < /p>
Код: Выделить всё
_tcpClient = new TcpClient();
_tcpClient.ReceiveTimeout = 40000;
_tcpClient.SendTimeout = 40000;
_tcpClient.ReceiveBufferSize = 40000;
UInt32 on = 1;
int size = sizeof(UInt32);
UInt32 keepAliveInterval = 1000;
UInt32 retryInterval = 100;
byte[] inArray = new byte[size * 3];
Array.Copy(BitConverter.GetBytes(on), 0, inArray, 0, size);
Array.Copy(BitConverter.GetBytes(keepAliveInterval), 0, inArray, size, size);
Array.Copy(BitConverter.GetBytes(retryInterval), 0, inArray, size * 2, size);
_tcpClient.Client.IOControl(IOControlCode.KeepAliveValues, inArray, null);
_tcpClient.Connect(HostName, Port);
_stream = new SslStream(_tcpClient.GetStream(), false, (object sender, X509Certificate? cert, X509Chain? chain, SslPolicyErrors policy) => true);
_stream.AuthenticateAsClient(HostName, _certs, SslProtocols.Tls12, true);
Console.WriteLine($"Authenticated: {_stream.IsAuthenticated}, HostName: {_stream.TargetHostName}, CypherSuite: {_stream.NegotiatedCipherSuite}, Protocol: {_stream.SslProtocol}, LeaveInnerStreamOpen: {_stream.LeaveInnerStreamOpen}");
_stream.Write(reqBytes);
request.OnRequestSent(Timestamp.GetTimestamp());
while (!_tcpClient.Client.Poll(1000000, SelectMode.SelectRead))
{
if (_internalState != InternalState.Started)
return null;
}
byteReads = _stream.Read(dataReceiv, 0, dataReceiv.Length);
if (byteReads == 0)
throw new Exception("Socket read error");
Wireshark Screen
Подробнее здесь:
https://stackoverflow.com/questions/794 ... -returns-0
1739803979
Anonymous
У меня есть странная проблема с SSLStream в моем приложении. закрыт) То же приложение, которое работает на той же ОС (Windows 11 23H2) в той же сети, работает правильно. тот же сервер. Есть идеи? p> Authenticated: true protocol: tls12 cyphersuite: tls_ecdhe_rsa_with_aes_128_cbc_sha256 LeaveInnerStreamoPen: false < /p> [code] _tcpClient = new TcpClient(); _tcpClient.ReceiveTimeout = 40000; _tcpClient.SendTimeout = 40000; _tcpClient.ReceiveBufferSize = 40000; UInt32 on = 1; int size = sizeof(UInt32); UInt32 keepAliveInterval = 1000; UInt32 retryInterval = 100; byte[] inArray = new byte[size * 3]; Array.Copy(BitConverter.GetBytes(on), 0, inArray, 0, size); Array.Copy(BitConverter.GetBytes(keepAliveInterval), 0, inArray, size, size); Array.Copy(BitConverter.GetBytes(retryInterval), 0, inArray, size * 2, size); _tcpClient.Client.IOControl(IOControlCode.KeepAliveValues, inArray, null); _tcpClient.Connect(HostName, Port); _stream = new SslStream(_tcpClient.GetStream(), false, (object sender, X509Certificate? cert, X509Chain? chain, SslPolicyErrors policy) => true); _stream.AuthenticateAsClient(HostName, _certs, SslProtocols.Tls12, true); Console.WriteLine($"Authenticated: {_stream.IsAuthenticated}, HostName: {_stream.TargetHostName}, CypherSuite: {_stream.NegotiatedCipherSuite}, Protocol: {_stream.SslProtocol}, LeaveInnerStreamOpen: {_stream.LeaveInnerStreamOpen}"); _stream.Write(reqBytes); request.OnRequestSent(Timestamp.GetTimestamp()); while (!_tcpClient.Client.Poll(1000000, SelectMode.SelectRead)) { if (_internalState != InternalState.Started) return null; } byteReads = _stream.Read(dataReceiv, 0, dataReceiv.Length); if (byteReads == 0) throw new Exception("Socket read error"); [/code] Wireshark Screen Подробнее здесь: [url]https://stackoverflow.com/questions/79439214/sslstream-read-returns-0[/url]