Peer review feedback. Handle socket.Connect() failures.

This commit is contained in:
David Garske 2020-03-18 13:33:15 -07:00
parent 00a49dffd0
commit a28fc5e70b
2 changed files with 28 additions and 10 deletions

View File

@ -107,13 +107,16 @@ public class wolfSSL_TLS_CSHarp
wolfssl.get_ciphers(ciphers, 4096); wolfssl.get_ciphers(ciphers, 4096);
Console.WriteLine("Ciphers : " + ciphers.ToString()); Console.WriteLine("Ciphers : " + ciphers.ToString());
//ciphers = new StringBuilder("ECDHE-ECDSA-AES128-GCM-SHA256"); /* Uncomment Section to enable specific cipher suite */
//if (wolfssl.CTX_set_cipher_list(ctx, ciphers) != wolfssl.SUCCESS) #if false
//{ ciphers = new StringBuilder("ECDHE-ECDSA-AES128-GCM-SHA256");
// Console.WriteLine("ERROR CTX_set_cipher_list()"); if (wolfssl.CTX_set_cipher_list(ctx, ciphers) != wolfssl.SUCCESS)
// wolfssl.CTX_free(ctx); {
// return; Console.WriteLine("ERROR CTX_set_cipher_list()");
//} wolfssl.CTX_free(ctx);
return;
}
#endif
short minDhKey = 128; short minDhKey = 128;
wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey); wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
@ -129,8 +132,23 @@ public class wolfSSL_TLS_CSHarp
/* set up TCP socket */ /* set up TCP socket */
tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp); ProtocolType.Tcp);
tcp.Connect("127.0.0.1", 11111); try
Console.WriteLine("Connection established"); {
tcp.Connect("localhost", 11111);
}
catch (Exception e)
{
Console.WriteLine("tcp.Connect() error " + e.ToString());
wolfssl.CTX_free(ctx);
return;
}
if (!tcp.Connected)
{
Console.WriteLine("tcp.Connect() failed!");
tcp.Close();
wolfssl.CTX_free(ctx);
return;
}
Console.WriteLine("Connected TCP"); Console.WriteLine("Connected TCP");
ssl = wolfssl.new_ssl(ctx); ssl = wolfssl.new_ssl(ctx);

View File