diff --git a/wrapper/CSharp/README.md b/wrapper/CSharp/README.md index d19adbc25..a4f7ab4d7 100644 --- a/wrapper/CSharp/README.md +++ b/wrapper/CSharp/README.md @@ -30,7 +30,7 @@ apt-get upgrade apt-get install mono-complete ``` -# Build wolfSSL and install +### Build wolfSSL and install ``` ./autogen.sh @@ -40,24 +40,42 @@ make check sudo make install ``` -# Build and run the wrapper +### Build and run the wrapper ``` cd wrapper/CSharp +``` +Building the server: +``` mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs \ - wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs +wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs && \ +cp wolfSSL_CSharp/wolfSSL.exe ../../certs/server.exe ``` -# Run the example - +Building the client: +``` +mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs \ +wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs && \ +cp wolfSSL_CSharp/wolfSSL.exe ../../certs/client.exe +``` + +### Run the example + +In one terminal instance run: ``` -cp wolfSSL_CSharp/wolfSSL.exe ../../certs cd ../../certs -mono wolfSSL.exe - -Calling ctx Init from wolfSSL -Finished init of ctx .... now load in cert and key -Ciphers : TLS13-AES128-GCM-SHA256:TLS13-AES256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305-OLD:ECDHE-ECDSA-CHACHA20-POLY1305-OLD:DHE-RSA-CHACHA20-POLY1305-OLD -Started TCP and waiting for a connection +mono server.exe +``` + +And in another terminal instance run: +``` +cd ../../certs +mono client.exe +``` + +### Enabling SNI +To enable SNI, just pass the `-S` argument with the specified hostname: +``` +mono client.exe -S hostname ``` diff --git a/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs b/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs index 5a018d85a..e8e4e9ae6 100644 --- a/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs +++ b/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs @@ -65,20 +65,21 @@ public class wolfSSL_TLS_Client /// wolfSSL. /// Parameters passed via command line /// - private static bool haveSNI(string[] args) + private static bool haveSNI(string[] args) { - if (args != null && args.Length == 2 && args[0] == "-S") - { - Console.WriteLine("SNI IS: ON"); - return true; - } - else { - Console.WriteLine("SNI IS: OFF"); - return false; + bool sniON = false; + for (int i = 0; i < args.Length; i++) { + if (args[i] == "-S") { + sniON = true; + break; + } } + Console.WriteLine("SNI IS: " + sniON); + return sniON; } + public static void Main(string[] args) { IntPtr ctx; diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs index 7803febc3..2a5137851 100644 --- a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs +++ b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs @@ -53,17 +53,17 @@ public class wolfSSL_TLS_CSHarp /// wolfSSL. /// Parameters passed via command line /// - private static bool haveSNI(string[] args) + private static bool haveSNI(string[] args) { - if (args != null && args.Length == 2 && args[0] == "-S") - { - Console.WriteLine("SNI IS: ON"); - return true; - } - else { - Console.WriteLine("SNI IS: OFF"); - return false; + bool sniON = false; + for (int i = 0; i < args.Length; i++) { + if (args[i] == "-S") { + sniON = true; + break; + } } + Console.WriteLine("SNI IS: " + sniON); + return sniON; } ///