TLS Client

As of version 1.4.2.12 OpenSSL Library for .NET ships with a TLS client class compatible with TLS version 1.3.

Sample usage of the DidiSoft.OpenSsl.Tls.TlsClient class can be seen below:

 

using DidiSoft.OpenSsl.Tls;
 
public void TestTls()
{
  using (TlsClient client = new TlsClient(TlsClient.TlsProtocol.Tls1_3))
  {
    string serverHello = client.Connect("localhost", 8888);
 
    client.Write("my data");
 
    string serverResponse = client.Read();
    Console.WriteLine(serveresponse);
  }
}

For asynchronous programming the child class DidiSoft.OpenSsl.Tls.TlsClientAsync can be used with its async methods:

using DidiSoft.OpenSsl.Tls;
 
public async void TestTlsAync()
{
 using (TlsClientAsync client = new TlsClientAsync(TlsClient.TlsProtocol.Tls1_3))
 {
  string serverHello = await client.ConnectAsync("localhost", 8888);
 
  await client.WriteAsync("my data");
 
  string serverResponse = await client.ReadAsync();
  Console.WriteLine(serverResponse);
 }
}