public async Task ServerAndClientShouldJustWorkInSsl() { using var server = TcpConnectionFactory.CreateSslServer(11000, new SslServerConnectionSettings( sslCertificate: new X509Certificate(Utils.LoadResourceAsByteArray("transact-tcp_pfx"), "password") )); using var client = TcpConnectionFactory.CreateSslClient(IPAddress.Loopback, 11000, connectionSettings: new SslClientConnectionSettings( sslServerHost: "transact-tcp", sslValidateServerCertificateCallback: ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true //pass everything )); var receivedFromClientEvent = new AsyncAutoResetEvent(false); var receivedFromServerEvent = new AsyncAutoResetEvent(false); client.Start( receivedAction: (c, data) => { if (Encoding.UTF8.GetString(data) == "SENT FROM SERVER") { receivedFromServerEvent.Set(); } }, connectionStateChangedAction: (c, fromState, toState) => { } ); server.Start( receivedAction: (c, data) => { if (Encoding.UTF8.GetString(data) == "SENT FROM CLIENT") { receivedFromClientEvent.Set(); } }, connectionStateChangedAction: (c, fromState, toState) => { } ); //WaitHandle.WaitAll(new[] { clientConnectedEvent, serverConnectedEvent }, 4000).ShouldBeTrue(); await client.WaitForStateAsync(ConnectionState.Connected); await server.WaitForStateAsync(ConnectionState.Connected); await client.SendDataAsync(Encoding.UTF8.GetBytes("SENT FROM CLIENT")); await server.SendDataAsync(Encoding.UTF8.GetBytes("SENT FROM SERVER")); //WaitHandle.WaitAll(new[] { receivedFromClientEvent, receivedFromServerEvent }, 4000).ShouldBeTrue(); (await receivedFromClientEvent.WaitAsync(10000)).ShouldBeTrue(); (await receivedFromServerEvent.WaitAsync(10000)).ShouldBeTrue(); }