forked from wolfSSL/wolfssl
Peer review feedback. Handle socket.Connect() failures.
This commit is contained in:
@ -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);
|
||||||
|
2
wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
Normal file → Executable file
2
wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
Normal file → Executable file
@ -18,7 +18,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
Reference in New Issue
Block a user