I got the problem with my code I'm trying to create sslStream between client and server but I'm getting the next error:
Request error: System.Security.Authentication.AuthenticationException: Cannot determine the frame size or a corrupted frame was received. at System.Net.Security.SslStream.GetFrameSize(ReadOnlySpan'1 buffer) at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder'1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](CancellationToken cancellationToken) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) at Node.ProxyServer.OnAcceptSocketAsync() in /Users/main/Desktop/Node/Node/ProxyServer.cs:line 162
So this error is caused by await sslStream.AuthenticateAsServerAsync line and I can't figure out why it doesn't work.
private async Task OnAcceptSocketAsync()
{
while (ListeningSocket != null)
{
try
{
var accept = await ListeningSocket.AcceptAsync();
SslStream sslStream = new SslStream(new NetworkStream(accept), false);
await sslStream.AuthenticateAsServerAsync(ServerCertificate, clientCertificateRequired: false, SslProtocols.Default, checkCertificateRevocation: true);
TunnelStructure tunnel = new TunnelStructure()
{
key = Guid.NewGuid(),
client = accept,
sslClientStream = sslStream,
};
await ConnectAsync(tunnel);
}
catch (Exception e)
{
}
}
}
I have tried to validate server and client certificate, specified different SslProtocols but no changes.