question

subkawa-2996 avatar image
0 Votes"
subkawa-2996 asked ·

how to send out a TLS Alert during handshaking

I'm trying to use TLS to communicate between computers in a local network.
So I implemented the server in OpenSSL(C++) and the client in C#, .NET Framework 4.7.2.

I execute TLS handshake by SSL_accept of OpenSSL and AuthenticateAsClient of C#, but currently the client does not send TLS alerts to the server when an error occurs during the handshake.
(For example, if the client does not accept the certificate, it should send out unknown_ca, but now the server is not notified and the handshake proceeds to the end.)
I implemented the client as follows:

private static ManualResetEvent connectDone = new ManualResetEvent(false);

static void Main(string[] args)
{
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(args[0]), 2500);
IAsyncResult result = socket.BeginConnect(ipEndPoint, new AsyncCallback(OnConnectServer), socket);

     connectDone.WaitOne();
 }

}

private static void OnConnectServer(IAsyncResult asyncResult)
{
Socket socket = (Socket)asyncResult.AsyncState;
socket.EndConnect(asyncResult);

 SslStream sslStream = new SslStream(
     new NetworkStream(socket),
     false,
     new RemoteCertificateValidationCallback(CertificateValidation)
 );

 try
 {
     sslStream.AuthenticateAsClient(serverName);
 }
 catch (AuthenticationException ex)
 {
     Console.WriteLine(ex.Message);
 }
 sslStream.Close();
 connectDone.Set();

}

Does anyone know how to send an alert from the client?

Thanks.










dotnet-csharpdotnet-runtime-framework
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers