Browse Source

no code change; CRLF line endings, trailing spaces

gojimmypi 1 year ago
parent
commit
91d2ff1fe9
36 changed files with 3120 additions and 3120 deletions
  1. 1 1
      wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config
  2. 5 5
      wrapper/CSharp/wolfSSL-DTLS-PSK-Server/Properties/AssemblyInfo.cs
  3. 5 5
      wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs
  4. 1 1
      wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj
  5. 1 1
      wrapper/CSharp/wolfSSL-DTLS-Server/App.config
  6. 5 5
      wrapper/CSharp/wolfSSL-DTLS-Server/Properties/AssemblyInfo.cs
  7. 3 3
      wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs
  8. 1 1
      wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj
  9. 1 1
      wrapper/CSharp/wolfSSL-Example-IOCallbacks/App.config
  10. 5 5
      wrapper/CSharp/wolfSSL-Example-IOCallbacks/Properties/AssemblyInfo.cs
  11. 4 4
      wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs
  12. 1 1
      wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.csproj
  13. 5 5
      wrapper/CSharp/wolfSSL-TLS-Client/App.config
  14. 36 36
      wrapper/CSharp/wolfSSL-TLS-Client/Properties/AssemblyInfo.cs
  15. 210 210
      wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs
  16. 123 123
      wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.csproj
  17. 6 6
      wrapper/CSharp/wolfSSL-TLS-PSK-Client/App.config
  18. 36 36
      wrapper/CSharp/wolfSSL-TLS-PSK-Client/Properties/AssemblyInfo.cs
  19. 82 82
      wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs
  20. 115 115
      wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.csproj
  21. 1 1
      wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config
  22. 5 5
      wrapper/CSharp/wolfSSL-TLS-PSK-Server/Properties/AssemblyInfo.cs
  23. 4 4
      wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs
  24. 1 1
      wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj
  25. 1 1
      wrapper/CSharp/wolfSSL-TLS-Server/App.config
  26. 5 5
      wrapper/CSharp/wolfSSL-TLS-Server/Properties/AssemblyInfo.cs
  27. 2 2
      wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
  28. 1 1
      wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj
  29. 5 5
      wrapper/CSharp/wolfSSL-TLS-ServerThreaded/App.config
  30. 36 36
      wrapper/CSharp/wolfSSL-TLS-ServerThreaded/Properties/AssemblyInfo.cs
  31. 194 194
      wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs
  32. 123 123
      wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.csproj
  33. 5 5
      wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs
  34. 73 73
      wrapper/CSharp/wolfSSL_CSharp/X509.cs
  35. 2017 2017
      wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
  36. 1 1
      wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj

+ 1 - 1
wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <startup> 
+    <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
 </configuration>

+ 5 - 5
wrapper/CSharp/wolfSSL-DTLS-PSK-Server/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL-DTLS-PSK-Server")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 5 - 5
wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs

@@ -18,9 +18,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
-
+
+
+
 
 using System;
 
@@ -48,12 +48,12 @@ public class wolfSSL_DTLS_PSK_Server
     /// <returns>size of key set</returns>
     public static uint my_psk_server_cb(IntPtr ssl, string identity, IntPtr key, uint max_key)
     {
-        /* perform a check on the identity sent across 
+        /* perform a check on the identity sent across
          * log function must be set for print out of logging information
          */
         wolfssl.log(wolfssl.INFO_LOG, "PSK Client Identity = " + identity);
 
-        /* Use desired key, note must be a key smaller than max key size parameter 
+        /* Use desired key, note must be a key smaller than max key size parameter
             Replace this with desired key. Is trivial one for testing */
         if (max_key < 4)
             return 0;

+ 1 - 1
wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj

@@ -77,7 +77,7 @@
     <PreBuildEvent>
     </PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>

+ 1 - 1
wrapper/CSharp/wolfSSL-DTLS-Server/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <startup> 
+    <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
 </configuration>

+ 5 - 5
wrapper/CSharp/wolfSSL-DTLS-Server/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL-DTLS-Server")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 3 - 3
wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs

@@ -18,9 +18,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
-
+
+
+
 
 using System;
 using System.Runtime.InteropServices;

+ 1 - 1
wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj

@@ -78,7 +78,7 @@
     <PreBuildEvent>
     </PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>

+ 1 - 1
wrapper/CSharp/wolfSSL-Example-IOCallbacks/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <startup> 
+    <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
 </configuration>

+ 5 - 5
wrapper/CSharp/wolfSSL-Example-IOCallbacks/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL-Example-IOCallbacks")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 4 - 4
wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs

@@ -18,8 +18,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
+
+
 
 
 using System;
@@ -122,12 +122,12 @@ class wolfSSL_Example_IOCallbacks
     /// <returns>size of key set</returns>
     public static uint my_psk_server_cb(IntPtr ssl, string identity, IntPtr key, uint max_key)
     {
-        /* perform a check on the identity sent across 
+        /* perform a check on the identity sent across
          * log function must be set for print out of logging information
          */
         wolfssl.log(wolfssl.INFO_LOG, "PSK Client Identity = " + identity);
 
-        /* Use desired key, note must be a key smaller than max key size parameter 
+        /* Use desired key, note must be a key smaller than max key size parameter
             Replace this with desired key. Is trivial one for testing */
         if (max_key < 4)
             return 0;

+ 1 - 1
wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.csproj

@@ -74,7 +74,7 @@
     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>

+ 5 - 5
wrapper/CSharp/wolfSSL-TLS-Client/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
-    </startup>
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
 </configuration>

+ 36 - 36
wrapper/CSharp/wolfSSL-TLS-Client/Properties/AssemblyInfo.cs

@@ -1,36 +1,36 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("wolfSSL-TLS-Client")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("wolfSSL")]
-[assembly: AssemblyProduct("wolfSSL-TLS-Client")]
-[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("05aad2b4-445e-4f0e-8e16-8f8512696505")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.0.0")]
-[assembly: AssemblyFileVersion("1.1.0.0")]
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("wolfSSL-TLS-Client")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("wolfSSL")]
+[assembly: AssemblyProduct("wolfSSL-TLS-Client")]
+[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("05aad2b4-445e-4f0e-8e16-8f8512696505")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]

+ 210 - 210
wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs

@@ -1,210 +1,210 @@
-/* wolfSSL-TLS-Client.cs
- *
- * Copyright (C) 2006-2023 wolfSSL Inc.
- *
- * This file is part of wolfSSL.
- *
- * wolfSSL is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * wolfSSL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
- */
-
-
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using wolfSSL.CSharp;
-
-public class wolfSSL_TLS_Client
-{
-    /// <summary>
-    /// Example of a logging function
-    /// </summary>
-    /// <param name="lvl">level of log</param>
-    /// <param name="msg">message to log</param>
-    public static void standard_log(int lvl, StringBuilder msg)
-    {
-        Console.WriteLine(msg);
-    }
-
-
-    private static void clean(IntPtr ssl, IntPtr ctx)
-    {
-        wolfssl.free(ssl);
-        wolfssl.CTX_free(ctx);
-        wolfssl.Cleanup();
-    }
-
-    /// <summary>
-    /// Verification callback
-    /// </summary>
-    /// <param name="preverify">1=Verify Okay, 0=Failure</param>
-    /// <param name="x509_ctx">Certificate in WOLFSSL_X509_STORE_CTX format</param>
-    private static int myVerify(int preverify, IntPtr x509_ctx)
-    {
-        /* Use the provided verification */
-        /* Can optionally override failures by returning non-zero value */
-        return preverify;
-    }
-
-    public static void Main(string[] args)
-    {
-        IntPtr ctx;
-        IntPtr ssl;
-        Socket tcp;
-
-        /* These paths should be changed for use */
-        string caCert = @"ca-cert.pem";
-        StringBuilder dhparam = new StringBuilder("dh2048.pem");
-
-        StringBuilder buff = new StringBuilder(1024);
-        StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
-
-        //example of function used for setting logging
-        wolfssl.SetLogging(standard_log);
-
-        wolfssl.Init();
-
-
-        Console.WriteLine("Calling ctx Init from wolfSSL");
-        ctx = wolfssl.CTX_new(wolfssl.usev23_client());
-        if (ctx == IntPtr.Zero)
-        {
-            Console.WriteLine("Error in creating ctx structure");
-            return;
-        }
-        Console.WriteLine("Finished init of ctx .... now load in CA");
-
-
-        if (!File.Exists(caCert))
-        {
-            Console.WriteLine("Could not find CA cert file");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-
-        if (wolfssl.CTX_load_verify_locations(ctx, caCert, null)
-            != wolfssl.SUCCESS)
-        {
-            Console.WriteLine("Error loading CA cert");
-        }
-
-        StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
-        wolfssl.get_ciphers(ciphers, 4096);
-        Console.WriteLine("Ciphers : " + ciphers.ToString());
-
-        /* Uncomment Section to enable specific cipher suite */
-#if false
-        ciphers = new StringBuilder("ECDHE-ECDSA-AES128-GCM-SHA256");
-        if (wolfssl.CTX_set_cipher_list(ctx, ciphers) != wolfssl.SUCCESS)
-        {
-            Console.WriteLine("ERROR CTX_set_cipher_list()");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-#endif
-
-        short minDhKey = 128;
-        wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
-
-        /* Setup Verify Callback */
-        if (wolfssl.CTX_set_verify(ctx, wolfssl.SSL_VERIFY_PEER, myVerify) 
-            != wolfssl.SUCCESS)
-        {
-            Console.WriteLine("Error setting verify callback!");
-        }
-
-
-        /* set up TCP socket */
-        tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
-                              ProtocolType.Tcp);
-        try
-        {
-            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");
-        ssl = wolfssl.new_ssl(ctx);
-        if (ssl == IntPtr.Zero)
-        {
-            Console.WriteLine("Error in creating ssl object");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-        Console.WriteLine("Connection made wolfSSL_connect ");
-        if (wolfssl.set_fd(ssl, tcp) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine(wolfssl.get_error(ssl));
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-
-        wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM);
-
-        if (wolfssl.connect(ssl) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine(wolfssl.get_error(ssl));
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-
-        /* print out results of TLS/SSL accept */
-        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
-        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
-
-
-        if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
-        {
-            Console.WriteLine("Error in write");
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-
-        /* read and print out the message then reply */
-        if (wolfssl.read(ssl, buff, 1023) < 0)
-        {
-            Console.WriteLine("Error in read");
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-        Console.WriteLine(buff);
-
-        wolfssl.shutdown(ssl);
-        tcp.Close();
-        clean(ssl, ctx);
-    }
-}
+/* wolfSSL-TLS-Client.cs
+ *
+ * Copyright (C) 2006-2023 wolfSSL Inc.
+ *
+ * This file is part of wolfSSL.
+ *
+ * wolfSSL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wolfSSL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
+ */
+
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using wolfSSL.CSharp;
+
+public class wolfSSL_TLS_Client
+{
+    /// <summary>
+    /// Example of a logging function
+    /// </summary>
+    /// <param name="lvl">level of log</param>
+    /// <param name="msg">message to log</param>
+    public static void standard_log(int lvl, StringBuilder msg)
+    {
+        Console.WriteLine(msg);
+    }
+
+
+    private static void clean(IntPtr ssl, IntPtr ctx)
+    {
+        wolfssl.free(ssl);
+        wolfssl.CTX_free(ctx);
+        wolfssl.Cleanup();
+    }
+
+    /// <summary>
+    /// Verification callback
+    /// </summary>
+    /// <param name="preverify">1=Verify Okay, 0=Failure</param>
+    /// <param name="x509_ctx">Certificate in WOLFSSL_X509_STORE_CTX format</param>
+    private static int myVerify(int preverify, IntPtr x509_ctx)
+    {
+        /* Use the provided verification */
+        /* Can optionally override failures by returning non-zero value */
+        return preverify;
+    }
+
+    public static void Main(string[] args)
+    {
+        IntPtr ctx;
+        IntPtr ssl;
+        Socket tcp;
+
+        /* These paths should be changed for use */
+        string caCert = @"ca-cert.pem";
+        StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+        StringBuilder buff = new StringBuilder(1024);
+        StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
+
+        //example of function used for setting logging
+        wolfssl.SetLogging(standard_log);
+
+        wolfssl.Init();
+
+
+        Console.WriteLine("Calling ctx Init from wolfSSL");
+        ctx = wolfssl.CTX_new(wolfssl.usev23_client());
+        if (ctx == IntPtr.Zero)
+        {
+            Console.WriteLine("Error in creating ctx structure");
+            return;
+        }
+        Console.WriteLine("Finished init of ctx .... now load in CA");
+
+
+        if (!File.Exists(caCert))
+        {
+            Console.WriteLine("Could not find CA cert file");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+
+        if (wolfssl.CTX_load_verify_locations(ctx, caCert, null)
+            != wolfssl.SUCCESS)
+        {
+            Console.WriteLine("Error loading CA cert");
+        }
+
+        StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
+        wolfssl.get_ciphers(ciphers, 4096);
+        Console.WriteLine("Ciphers : " + ciphers.ToString());
+
+        /* Uncomment Section to enable specific cipher suite */
+#if false
+        ciphers = new StringBuilder("ECDHE-ECDSA-AES128-GCM-SHA256");
+        if (wolfssl.CTX_set_cipher_list(ctx, ciphers) != wolfssl.SUCCESS)
+        {
+            Console.WriteLine("ERROR CTX_set_cipher_list()");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+#endif
+
+        short minDhKey = 128;
+        wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+
+        /* Setup Verify Callback */
+        if (wolfssl.CTX_set_verify(ctx, wolfssl.SSL_VERIFY_PEER, myVerify)
+            != wolfssl.SUCCESS)
+        {
+            Console.WriteLine("Error setting verify callback!");
+        }
+
+
+        /* set up TCP socket */
+        tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
+                              ProtocolType.Tcp);
+        try
+        {
+            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");
+        ssl = wolfssl.new_ssl(ctx);
+        if (ssl == IntPtr.Zero)
+        {
+            Console.WriteLine("Error in creating ssl object");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+        Console.WriteLine("Connection made wolfSSL_connect ");
+        if (wolfssl.set_fd(ssl, tcp) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine(wolfssl.get_error(ssl));
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+
+        wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM);
+
+        if (wolfssl.connect(ssl) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine(wolfssl.get_error(ssl));
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+
+        /* print out results of TLS/SSL accept */
+        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+
+        if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+        {
+            Console.WriteLine("Error in write");
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+
+        /* read and print out the message then reply */
+        if (wolfssl.read(ssl, buff, 1023) < 0)
+        {
+            Console.WriteLine("Error in read");
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+        Console.WriteLine(buff);
+
+        wolfssl.shutdown(ssl);
+        tcp.Close();
+        clean(ssl, ctx);
+    }
+}

+ 123 - 123
wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.csproj

@@ -1,123 +1,123 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>wolfSSL_TLS_Client</RootNamespace>
-    <AssemblyName>wolfSSL-TLS-Client</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>..\DLL Debug\Win32\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>3</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>..\DLL Release\Win32\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <StartupObject />
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\DLL Debug\x64\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <WarningLevel>4</WarningLevel>
-    <DebugType>full</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <OutputPath>..\DLL Release\x64</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="wolfSSL-TLS-Client.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
-      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
-      <Name>wolfSSL_CSharp</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
-      <Visible>False</Visible>
-      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PreBuildEvent>
-    </PreBuildEvent>
-  </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>wolfSSL_TLS_Client</RootNamespace>
+    <AssemblyName>wolfSSL-TLS-Client</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\DLL Debug\Win32\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\DLL Release\Win32\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>..\DLL Debug\x64\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>..\DLL Release\x64</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="wolfSSL-TLS-Client.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
+      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
+      <Name>wolfSSL_CSharp</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 6 - 6
wrapper/CSharp/wolfSSL-TLS-PSK-Client/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
-    </startup>
-</configuration>
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+    <startup>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
+    </startup>
+</configuration>

+ 36 - 36
wrapper/CSharp/wolfSSL-TLS-PSK-Client/Properties/AssemblyInfo.cs

@@ -1,36 +1,36 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("wolfSSL-TLS-PSK-Client")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("wolfSSL")]
-[assembly: AssemblyProduct("wolfSSL-TLS-PSK-Client")]
-[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("1de70ade-16d5-4c90-9657-c19c2762bca6")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.0.0")]
-[assembly: AssemblyFileVersion("1.1.0.0")]
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("wolfSSL-TLS-PSK-Client")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("wolfSSL")]
+[assembly: AssemblyProduct("wolfSSL-TLS-PSK-Client")]
+[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1de70ade-16d5-4c90-9657-c19c2762bca6")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]

+ 82 - 82
wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs

@@ -18,8 +18,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
+
+
 
 
 using System;
@@ -49,13 +49,13 @@ public class wolfSSL_TLS_PSK_Client
     /// <returns>size of key set</returns>
     public static uint my_psk_client_cb(IntPtr ssl, string hint, IntPtr identity, uint id_max, IntPtr key, uint max_key)
     {
-        /* C# client */
-        byte[] id = { 67, 35, 32, 99, 108, 105, 101, 110, 116 };
+        /* C# client */
+        byte[] id = { 67, 35, 32, 99, 108, 105, 101, 110, 116 };
         if (id_max < 9)
             return 0;
         Marshal.Copy(id, 0, identity, 9);
-
-        /* Use desired key, note must be a key smaller than max key size parameter 
+
+        /* Use desired key, note must be a key smaller than max key size parameter
             Replace this with desired key. Is trivial one for testing */
         if (max_key < 4)
             return 0;
@@ -76,9 +76,9 @@ public class wolfSSL_TLS_PSK_Client
 
     public static void Main(string[] args)
     {
-        IntPtr ctx;
-        IntPtr ssl;
-        Socket tcp;
+        IntPtr ctx;
+        IntPtr ssl;
+        Socket tcp;
 
         wolfssl.psk_client_delegate psk_cb = new wolfssl.psk_client_delegate(my_psk_client_cb);
 
@@ -118,81 +118,81 @@ public class wolfSSL_TLS_PSK_Client
         /* Test psk use with DHE */
         wolfssl.CTX_set_psk_client_callback(ctx, psk_cb);
 
-        /* set up TCP socket */
-        tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
-                              ProtocolType.Tcp);
-        try
-        {
-            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");
-        ssl = wolfssl.new_ssl(ctx);
-        if (ssl == IntPtr.Zero)
-        {
-            Console.WriteLine("Error in creating ssl object");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-        if (wolfssl.set_fd(ssl, tcp) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine(wolfssl.get_error(ssl));
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
+        /* set up TCP socket */
+        tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
+                              ProtocolType.Tcp);
+        try
+        {
+            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");
+        ssl = wolfssl.new_ssl(ctx);
+        if (ssl == IntPtr.Zero)
+        {
+            Console.WriteLine("Error in creating ssl object");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+        if (wolfssl.set_fd(ssl, tcp) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine(wolfssl.get_error(ssl));
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
 
         wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM);
 
-        if (wolfssl.connect(ssl) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine(wolfssl.get_error(ssl));
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-
-        /* print out results of TLS/SSL accept */
-        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
-        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
-
-
-        if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
-        {
-            Console.WriteLine("Error in write");
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-
-        /* read and print out the message then reply */
-        if (wolfssl.read(ssl, buff, 1023) < 0)
-        {
-            Console.WriteLine("Error in read");
-            tcp.Close();
-            clean(ssl, ctx);
-            return;
-        }
-        Console.WriteLine(buff);
-
-        wolfssl.shutdown(ssl);
-        tcp.Close();
-        clean(ssl, ctx);
+        if (wolfssl.connect(ssl) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine(wolfssl.get_error(ssl));
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+
+        /* print out results of TLS/SSL accept */
+        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+
+        if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+        {
+            Console.WriteLine("Error in write");
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+
+        /* read and print out the message then reply */
+        if (wolfssl.read(ssl, buff, 1023) < 0)
+        {
+            Console.WriteLine("Error in read");
+            tcp.Close();
+            clean(ssl, ctx);
+            return;
+        }
+        Console.WriteLine(buff);
+
+        wolfssl.shutdown(ssl);
+        tcp.Close();
+        clean(ssl, ctx);
     }
 }

+ 115 - 115
wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.csproj

@@ -1,115 +1,115 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{4F92ECF5-A1D8-4A13-AD0C-6571EB03C01C}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>wolfSSL_TLS_PSK_Client</RootNamespace>
-    <AssemblyName>wolfSSL-TLS-PSK-Client</AssemblyName>
-    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <TargetFrameworkProfile />
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>..\DLL Debug\Win32\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>..\DLL Release\Win32\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\DLL Debug\x64\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <OutputPath>..\DLL Release\x64\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="wolfSSL-TLS-PSK-Client.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
-      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
-      <Name>wolfSSL_CSharp</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include=".NETFramework,Version=v4.8">
-      <Visible>False</Visible>
-      <ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PreBuildEvent>
-    </PreBuildEvent>
-  </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{4F92ECF5-A1D8-4A13-AD0C-6571EB03C01C}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>wolfSSL_TLS_PSK_Client</RootNamespace>
+    <AssemblyName>wolfSSL-TLS-PSK-Client</AssemblyName>
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\DLL Debug\Win32\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\DLL Release\Win32\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>..\DLL Debug\x64\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>..\DLL Release\x64\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="wolfSSL-TLS-PSK-Client.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
+      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
+      <Name>wolfSSL_CSharp</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.8">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 1 - 1
wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <startup> 
+    <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
 </configuration>

+ 5 - 5
wrapper/CSharp/wolfSSL-TLS-PSK-Server/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL-TLS-PSK-Server")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 4 - 4
wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs

@@ -18,8 +18,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
+
+
 
 
 using System;
@@ -47,12 +47,12 @@ public class wolfSSL_TLS_PSK_Server
     /// <returns>size of key set</returns>
     public static uint my_psk_server_cb(IntPtr ssl, string identity, IntPtr key, uint max_key)
     {
-        /* perform a check on the identity sent across 
+        /* perform a check on the identity sent across
          * log function must be set for print out of logging information
          */
         wolfssl.log(wolfssl.INFO_LOG, "PSK Client Identity = " + identity);
 
-        /* Use desired key, note must be a key smaller than max key size parameter 
+        /* Use desired key, note must be a key smaller than max key size parameter
             Replace this with desired key. Is trivial one for testing */
         if (max_key < 4)
             return 0;

+ 1 - 1
wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj

@@ -77,7 +77,7 @@
     <PreBuildEvent>
     </PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>

+ 1 - 1
wrapper/CSharp/wolfSSL-TLS-Server/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <startup> 
+    <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
 </configuration>

+ 5 - 5
wrapper/CSharp/wolfSSL-TLS-Server/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL-TLS-Server")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 2 - 2
wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs

@@ -18,8 +18,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
+
+
 
 
 using System;

+ 1 - 1
wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj

@@ -113,7 +113,7 @@
     <PreBuildEvent>
     </PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>

+ 5 - 5
wrapper/CSharp/wolfSSL-TLS-ServerThreaded/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
-    </startup>
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
 </configuration>

+ 36 - 36
wrapper/CSharp/wolfSSL-TLS-ServerThreaded/Properties/AssemblyInfo.cs

@@ -1,36 +1,36 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("wolfSSL-TLS-ServerThreaded")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("wolfSSL")]
-[assembly: AssemblyProduct("wolfSSL-TLS-ServerThreaded")]
-[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("716e8f30-1318-4e3b-b788-d0380b397a4c")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.0.0")]
-[assembly: AssemblyFileVersion("1.1.0.0")]
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("wolfSSL-TLS-ServerThreaded")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("wolfSSL")]
+[assembly: AssemblyProduct("wolfSSL-TLS-ServerThreaded")]
+[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("716e8f30-1318-4e3b-b788-d0380b397a4c")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]

+ 194 - 194
wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs

@@ -1,194 +1,194 @@
-/* wolfSSL-TLS-ServerThreaded.cs
- *
- * Copyright (C) 2006-2023 wolfSSL Inc.
- *
- * This file is part of wolfSSL.
- *
- * wolfSSL is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * wolfSSL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
- */
-
-
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using System.Threading;
-
-using wolfSSL.CSharp;
-
-public class wolfSSL_TLS_ServerThread
-{
-    private IntPtr _ctx;
-    private Socket _fd;
-
-    public wolfSSL_TLS_ServerThread(IntPtr ctx, Socket fd)
-    {
-        _ctx = ctx;
-        _fd = fd;        
-    }
-
-    private const int kEchoBufSz = 1024;
-    public void start_client() 
-    {
-        StringBuilder buff = new StringBuilder(kEchoBufSz);
-        IntPtr ssl = wolfssl.new_ssl(_ctx);
-        if (ssl == IntPtr.Zero)
-        {
-            Console.WriteLine("Error in creating ssl object");
-            return;
-        }
-
-        if (wolfssl.set_fd(ssl, _fd) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine(wolfssl.get_error(ssl));
-            _fd.Close();
-            wolfssl.free(ssl);
-            return;
-        }
-
-        Console.WriteLine("Starting TLS handshake");
-        if (wolfssl.accept(ssl) != wolfssl.SUCCESS)
-        {
-            /* get and print out the error */
-            Console.WriteLine("Failed " + wolfssl.get_error(ssl));
-            _fd.Close();
-            wolfssl.free(ssl);
-            return;
-        }
-
-        /* print out results of TLS/SSL accept */
-        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
-        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
-
-        /* echo data until error */
-        while (true)
-        {
-            /* read and print out the message then reply */
-            if (wolfssl.read(ssl, buff, kEchoBufSz-1) < 0)
-            {
-                Console.WriteLine("Error in read");
-                break;
-            }
-            Console.WriteLine(buff);
-
-            if (wolfssl.write(ssl, buff, buff.Length) != buff.Length)
-            {
-                Console.WriteLine("Error in write");
-                break;
-            }
-        }
-
-        Console.WriteLine("Closing " + wolfssl.get_error(ssl));
-        _fd.Close();
-        wolfssl.free(ssl);
-    }
-}
-
-public class wolfSSL_TLS_ServerThreaded
-{
-    /// <summary>
-    /// Example of a logging function
-    /// </summary>
-    /// <param name="lvl">level of log</param>
-    /// <param name="msg">message to log</param>
-    public static void standard_log(int lvl, StringBuilder msg)
-    {
-        Console.WriteLine(msg);
-    }
-
-    public static void Main(string[] args)
-    {
-        IntPtr ctx;
-
-        /* These paths should be changed for use */
-        string fileCert = @"server-cert.pem";
-        string fileKey = @"server-key.pem";
-        StringBuilder dhparam = new StringBuilder("dh2048.pem");
-
-        /* example of function used for setting logging */
-        wolfssl.SetLogging(standard_log);
-        wolfssl.Init();
-
-        Console.WriteLine("Calling ctx Init from wolfSSL");
-        ctx = wolfssl.CTX_new(wolfssl.usev23_server());
-        if (ctx == IntPtr.Zero)
-        {
-            Console.WriteLine("Error in creating ctx structure");
-            return;
-        }
-        Console.WriteLine("Finished init of ctx .... now load in cert and key");
-
-        if (!File.Exists(fileCert) || !File.Exists(fileKey))
-        {
-            Console.WriteLine("Could not find cert or key file");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-        if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
-        {
-            Console.WriteLine("Error in setting cert file");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-        if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
-        {
-            Console.WriteLine("Error in setting key file");
-            wolfssl.CTX_free(ctx);
-            return;
-        }
-
-        StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
-        wolfssl.get_ciphers(ciphers, 4096);
-        Console.WriteLine("Ciphers : " + ciphers.ToString());
-
-        short minDhKey = 128;
-        wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
-        wolfssl.CTX_SetTmpDH_file(ctx, dhparam, wolfssl.SSL_FILETYPE_PEM);
-
-        /* set up TCP socket */
-        IPAddress ip = IPAddress.Parse("0.0.0.0"); /* bind to any */
-        TcpListener tcp = new TcpListener(ip, 11111);
-        tcp.Start();
-
-        Console.WriteLine("Started TCP and waiting for a connection");
-
-        while (true) {
-            try
-            {
-                Socket fd = tcp.AcceptSocket();
-                Console.WriteLine("Got client connection");
-
-                /* Spin up thread for client */
-                wolfSSL_TLS_ServerThread thread = new wolfSSL_TLS_ServerThread(ctx, fd);
-                Thread thr = new Thread(new ThreadStart(thread.start_client));
-                thr.Start();
-            }
-            catch(Exception ex)
-            {
-                Console.WriteLine("Server Exception " + ex.ToString());
-                break;
-            }
-        }
-        
-        tcp.Stop();
-        wolfssl.CTX_free(ctx);
-        wolfssl.Cleanup();
-    }
-}
+/* wolfSSL-TLS-ServerThreaded.cs
+ *
+ * Copyright (C) 2006-2023 wolfSSL Inc.
+ *
+ * This file is part of wolfSSL.
+ *
+ * wolfSSL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wolfSSL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
+ */
+
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+using wolfSSL.CSharp;
+
+public class wolfSSL_TLS_ServerThread
+{
+    private IntPtr _ctx;
+    private Socket _fd;
+
+    public wolfSSL_TLS_ServerThread(IntPtr ctx, Socket fd)
+    {
+        _ctx = ctx;
+        _fd = fd;
+    }
+
+    private const int kEchoBufSz = 1024;
+    public void start_client()
+    {
+        StringBuilder buff = new StringBuilder(kEchoBufSz);
+        IntPtr ssl = wolfssl.new_ssl(_ctx);
+        if (ssl == IntPtr.Zero)
+        {
+            Console.WriteLine("Error in creating ssl object");
+            return;
+        }
+
+        if (wolfssl.set_fd(ssl, _fd) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine(wolfssl.get_error(ssl));
+            _fd.Close();
+            wolfssl.free(ssl);
+            return;
+        }
+
+        Console.WriteLine("Starting TLS handshake");
+        if (wolfssl.accept(ssl) != wolfssl.SUCCESS)
+        {
+            /* get and print out the error */
+            Console.WriteLine("Failed " + wolfssl.get_error(ssl));
+            _fd.Close();
+            wolfssl.free(ssl);
+            return;
+        }
+
+        /* print out results of TLS/SSL accept */
+        Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+        Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+        /* echo data until error */
+        while (true)
+        {
+            /* read and print out the message then reply */
+            if (wolfssl.read(ssl, buff, kEchoBufSz-1) < 0)
+            {
+                Console.WriteLine("Error in read");
+                break;
+            }
+            Console.WriteLine(buff);
+
+            if (wolfssl.write(ssl, buff, buff.Length) != buff.Length)
+            {
+                Console.WriteLine("Error in write");
+                break;
+            }
+        }
+
+        Console.WriteLine("Closing " + wolfssl.get_error(ssl));
+        _fd.Close();
+        wolfssl.free(ssl);
+    }
+}
+
+public class wolfSSL_TLS_ServerThreaded
+{
+    /// <summary>
+    /// Example of a logging function
+    /// </summary>
+    /// <param name="lvl">level of log</param>
+    /// <param name="msg">message to log</param>
+    public static void standard_log(int lvl, StringBuilder msg)
+    {
+        Console.WriteLine(msg);
+    }
+
+    public static void Main(string[] args)
+    {
+        IntPtr ctx;
+
+        /* These paths should be changed for use */
+        string fileCert = @"server-cert.pem";
+        string fileKey = @"server-key.pem";
+        StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+        /* example of function used for setting logging */
+        wolfssl.SetLogging(standard_log);
+        wolfssl.Init();
+
+        Console.WriteLine("Calling ctx Init from wolfSSL");
+        ctx = wolfssl.CTX_new(wolfssl.usev23_server());
+        if (ctx == IntPtr.Zero)
+        {
+            Console.WriteLine("Error in creating ctx structure");
+            return;
+        }
+        Console.WriteLine("Finished init of ctx .... now load in cert and key");
+
+        if (!File.Exists(fileCert) || !File.Exists(fileKey))
+        {
+            Console.WriteLine("Could not find cert or key file");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+        if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+        {
+            Console.WriteLine("Error in setting cert file");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+        if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+        {
+            Console.WriteLine("Error in setting key file");
+            wolfssl.CTX_free(ctx);
+            return;
+        }
+
+        StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
+        wolfssl.get_ciphers(ciphers, 4096);
+        Console.WriteLine("Ciphers : " + ciphers.ToString());
+
+        short minDhKey = 128;
+        wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+        wolfssl.CTX_SetTmpDH_file(ctx, dhparam, wolfssl.SSL_FILETYPE_PEM);
+
+        /* set up TCP socket */
+        IPAddress ip = IPAddress.Parse("0.0.0.0"); /* bind to any */
+        TcpListener tcp = new TcpListener(ip, 11111);
+        tcp.Start();
+
+        Console.WriteLine("Started TCP and waiting for a connection");
+
+        while (true) {
+            try
+            {
+                Socket fd = tcp.AcceptSocket();
+                Console.WriteLine("Got client connection");
+
+                /* Spin up thread for client */
+                wolfSSL_TLS_ServerThread thread = new wolfSSL_TLS_ServerThread(ctx, fd);
+                Thread thr = new Thread(new ThreadStart(thread.start_client));
+                thr.Start();
+            }
+            catch(Exception ex)
+            {
+                Console.WriteLine("Server Exception " + ex.ToString());
+                break;
+            }
+        }
+
+        tcp.Stop();
+        wolfssl.CTX_free(ctx);
+        wolfssl.Cleanup();
+    }
+}

+ 123 - 123
wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.csproj

@@ -1,123 +1,123 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>wolfSSL_TLS_ServerThreaded</RootNamespace>
-    <AssemblyName>wolfSSL-TLS-ServerThreaded</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>..\DLL Debug\Win32\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>3</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>..\DLL Release\Win32\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <StartupObject />
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\DLL Debug\x64\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <WarningLevel>4</WarningLevel>
-    <DebugType>full</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <OutputPath>..\DLL Release\x64\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="wolfSSL-TLS-ServerThreaded.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
-      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
-      <Name>wolfSSL_CSharp</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
-      <Visible>False</Visible>
-      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PreBuildEvent>
-    </PreBuildEvent>
-  </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>wolfSSL_TLS_ServerThreaded</RootNamespace>
+    <AssemblyName>wolfSSL-TLS-ServerThreaded</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\DLL Debug\Win32\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\DLL Release\Win32\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>..\DLL Debug\x64\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>..\DLL Release\x64\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="wolfSSL-TLS-ServerThreaded.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\wolfSSL_CSharp\wolfSSL_CSharp.csproj">
+      <Project>{52609808-0418-46d3-8e17-141927a1a39a}</Project>
+      <Name>wolfSSL_CSharp</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 5 - 5
wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs

@@ -2,7 +2,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// General Information about an assembly is controlled through the following 
+// General Information about an assembly is controlled through the following
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("wolfSSL.CSharp")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
@@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
-//      Minor Version 
+//      Minor Version
 //      Build Number
 //      Revision
 //
-// You can specify all the values or you can default the Build and Revision Numbers 
+// You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.1.0.0")]

+ 73 - 73
wrapper/CSharp/wolfSSL_CSharp/X509.cs

@@ -1,6 +1,6 @@
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
 using System.Threading;
 
 namespace wolfSSL.CSharp
@@ -9,21 +9,21 @@ namespace wolfSSL.CSharp
     {
         private const string wolfssl_dll = "wolfssl.dll";
 
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static int wolfSSL_X509_get_pubkey_buffer(IntPtr x509, IntPtr buf, IntPtr bufSz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_get_der(IntPtr x509, IntPtr bufSz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static void wolfSSL_X509_free(IntPtr x509);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static int wc_DerToPem(IntPtr der, int derSz, IntPtr pem, int pemSz, int type);
 
 
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_get_name_oneline(IntPtr x509Name, IntPtr buf, int bufSz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_get_subject_name(IntPtr x509);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_get_issuer_name(IntPtr x509);
 
         private IntPtr x509;
@@ -71,74 +71,74 @@ namespace wolfSSL.CSharp
         }
 
 
-        /// <summary>
-        /// Used for getting the public key buffer
-        /// </summary>
-        /// <returns>DER public key on success</returns>
-        public byte[] GetPublicKey()
-        {
+        /// <summary>
+        /// Used for getting the public key buffer
+        /// </summary>
+        /// <returns>DER public key on success</returns>
+        public byte[] GetPublicKey()
+        {
             if (this.x509 == IntPtr.Zero)
             {
                 return null;
-            }
-
-            try
-            {
-                IntPtr bufSz;
-                IntPtr buf;
-
-                int keySz = 0;
-                int ret;
-                byte[] key = null;
-
-                bufSz = Marshal.AllocHGlobal(4); /* pointer to 4 bytes */
-                ret = wolfSSL_X509_get_pubkey_buffer(this.x509, IntPtr.Zero, bufSz);
-                if (ret == wolfssl.SUCCESS)
+            }
+
+            try
+            {
+                IntPtr bufSz;
+                IntPtr buf;
+
+                int keySz = 0;
+                int ret;
+                byte[] key = null;
+
+                bufSz = Marshal.AllocHGlobal(4); /* pointer to 4 bytes */
+                ret = wolfSSL_X509_get_pubkey_buffer(this.x509, IntPtr.Zero, bufSz);
+                if (ret == wolfssl.SUCCESS)
                 {
-                    keySz = Marshal.ReadInt32(bufSz, 0);
-                    buf = Marshal.AllocHGlobal(keySz);
-                    ret = wolfSSL_X509_get_pubkey_buffer(this.x509, buf, bufSz);
+                    keySz = Marshal.ReadInt32(bufSz, 0);
+                    buf = Marshal.AllocHGlobal(keySz);
+                    ret = wolfSSL_X509_get_pubkey_buffer(this.x509, buf, bufSz);
                     if (ret == wolfssl.SUCCESS)
                     {
                         key = new byte[keySz];
                         Marshal.Copy(buf, key, 0, keySz);
                     }
-                    Marshal.FreeHGlobal(buf);
+                    Marshal.FreeHGlobal(buf);
                 }
-                Marshal.FreeHGlobal(bufSz);
-                return key;
-            }
-            catch (Exception e)
-            {
-                wolfssl.log(wolfssl.ERROR_LOG, "error getting public key" + e.ToString());
-                return null;
-            }
+                Marshal.FreeHGlobal(bufSz);
+                return key;
+            }
+            catch (Exception e)
+            {
+                wolfssl.log(wolfssl.ERROR_LOG, "error getting public key" + e.ToString());
+                return null;
+            }
         }
 
-        /// <summary>
-        /// Gets the X509 buffer
-        /// </summary>
+        /// <summary>
+        /// Gets the X509 buffer
+        /// </summary>
         /// <returns>X509 buffer on success</returns>
         public byte[] Export(int type)
         {
-            if (this.x509 == IntPtr.Zero)
-                return null;
-            try
-            {
-                IntPtr bufSz;
-                IntPtr buf;
+            if (this.x509 == IntPtr.Zero)
+                return null;
+            try
+            {
+                IntPtr bufSz;
+                IntPtr buf;
                 byte[] ret = null;
 
-                bufSz = Marshal.AllocHGlobal(4); /* pointer to 4 bytes */
-                buf = wolfSSL_X509_get_der(this.x509, bufSz);
-                if (buf != IntPtr.Zero)
+                bufSz = Marshal.AllocHGlobal(4); /* pointer to 4 bytes */
+                buf = wolfSSL_X509_get_der(this.x509, bufSz);
+                if (buf != IntPtr.Zero)
                 {
                     int derSz = Marshal.ReadInt32(bufSz, 0);
                     if (type == wolfssl.SSL_FILETYPE_ASN1)
                     {
                         ret = new byte[derSz];
                         Marshal.Copy(buf, ret, 0, derSz);
-                    }
+                    }
                     else if (type == wolfssl.SSL_FILETYPE_PEM)
                     {
                         int pemSz;
@@ -153,41 +153,41 @@ namespace wolfSSL.CSharp
                             Marshal.FreeHGlobal(pem);
                         }
 
-                    }
+                    }
                     else
                     {
                         wolfssl.log(wolfssl.ERROR_LOG, "unsupported export type");
                     }
-                    Marshal.FreeHGlobal(bufSz);
-                    return ret;
+                    Marshal.FreeHGlobal(bufSz);
+                    return ret;
                 }
                 {
                     wolfssl.log(wolfssl.ERROR_LOG, "unable to get buffer");
                 }
-                Marshal.FreeHGlobal(bufSz);
-                return ret;
-            }
-            catch (Exception e)
-            {
-                wolfssl.log(wolfssl.ERROR_LOG, "error getting x509 DER" + e.ToString());
-                return null;
+                Marshal.FreeHGlobal(bufSz);
+                return ret;
+            }
+            catch (Exception e)
+            {
+                wolfssl.log(wolfssl.ERROR_LOG, "error getting x509 DER" + e.ToString());
+                return null;
             }
         }
 
-        /// <summary>
-        /// Gets the X509 buffer using this.type set (default PEM)
-        /// </summary>
+        /// <summary>
+        /// Gets the X509 buffer using this.type set (default PEM)
+        /// </summary>
         /// <returns>X509 buffer on success</returns>
         public byte[] Export()
         {
             return Export(this.type);
         }
 
-        /// <summary>
-        /// Gets the X509 format
-        /// </summary>
-        /// <returns>X509 format on success</returns>
-        public string GetFormat()
+        /// <summary>
+        /// Gets the X509 format
+        /// </summary>
+        /// <returns>X509 format on success</returns>
+        public string GetFormat()
         {
             if (this.type == wolfssl.SSL_FILETYPE_PEM)
             {

+ 2017 - 2017
wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs

@@ -1,5 +1,5 @@
-/* wolfSSL.cs
- *
+/* wolfSSL.cs
+ *
  * Copyright (C) 2006-2023 wolfSSL Inc.
  *
  * This file is part of wolfSSL.
@@ -18,2058 +18,2058 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
-
-
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-
-namespace wolfSSL.CSharp {
-    public class wolfssl
-    {
-        private const string wolfssl_dll = "wolfssl.dll";
-
-        /* wait for 6 seconds default on TCP socket state poll if timeout not set */
-        private const int WC_WAIT = 6000000;
-
-        /********************************
-         * Class for DTLS connections
-         */
-        /// <summary>
-        /// Contains information regarding a DTLS connection having UdpClient udp and IPEndPoint ep.
-        /// Used to keep memory alive.
-        /// </summary>
-        public class DTLS_con
-        {
-            public UdpClient udp;
-            public IPEndPoint ep;
-        }
-
-
-        /********************************
-         * Class for keeping ctx handles alive
-         */
-        [StructLayout(LayoutKind.Sequential)]
-        private class ctx_handle
-        {
-            private GCHandle rec_cb;
-            private GCHandle snd_cb;
-            private GCHandle psk_cb;
-            private GCHandle vrf_cb;
-            private IntPtr ctx;
-
-            public void set_receive(GCHandle input)
-            {
-                this.rec_cb = input;
-            }
-            public GCHandle get_receive()
-            {
-                return this.rec_cb;
-            }
-
-            public void set_send(GCHandle input)
-            {
-                this.snd_cb = input;
-            }
-            public GCHandle get_send()
-            {
-                return this.snd_cb;
-            }
-
-            public void set_psk(GCHandle input)
-            {
-                this.psk_cb = input;
-            }
-            public GCHandle get_psk()
-            {
-                return this.psk_cb;
-            }
-
-            public void set_vrf(GCHandle input)
-            {
-                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
-                {
-                    this.vrf_cb.Free();
-                }
-                this.vrf_cb = input;
-            }
-            public GCHandle get_vrf()
-            {
-                return this.vrf_cb;
-            }
-
-            public void set_ctx(IntPtr input)
-            {
-                this.ctx = input;
-            }
-            public IntPtr get_ctx()
-            {
-                return this.ctx;
-            }
-
-            /// <summary>
-            /// Called to free the pointers keeping handles alive
-            /// </summary>
-            public void free()
-            {
-                log(INFO_LOG, "freeing ctx handle");
-                if (!Object.Equals(this.rec_cb, default(GCHandle)))
-                {
-                    this.rec_cb.Free();
-                }
-                if (!Object.Equals(this.snd_cb, default(GCHandle)))
-                {
-                    this.snd_cb.Free();
-                }
-                if (!Object.Equals(this.psk_cb, default(GCHandle)))
-                {
-                    this.psk_cb.Free();
-                }
-                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
-                {
-                    this.vrf_cb.Free();
-                }
-            }
-        }
-
-        /********************************
-         * Class for keeping ssl handle alive
-         */
-        [StructLayout(LayoutKind.Sequential)]
-        private class ssl_handle
-        {
-            private GCHandle fd_pin;
-            private GCHandle psk_cb;
-            private GCHandle vrf_cb;
-            private IntPtr ssl;
-
-            public void set_fd(GCHandle input)
-            {
-                this.fd_pin = input;
-            }
-            public GCHandle get_fd()
-            {
-                return this.fd_pin;
-            }
-
-            public void set_psk(GCHandle input)
-            {
-                this.psk_cb = input;
-            }
-            public GCHandle get_psk()
-            {
-                return this.psk_cb;
-            }
-
-            public void set_vrf(GCHandle input)
-            {
-                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
-                {
-                    this.vrf_cb.Free();
-                }
-                this.vrf_cb = input;
-            }
-            public GCHandle get_vrf()
-            {
-                return this.vrf_cb;
-            }
-
-            public void set_ssl(IntPtr input)
-            {
-                this.ssl = input;
-            }
-            public IntPtr get_ssl()
-            {
-                return this.ssl;
-            }
-            public void free()
-            {
+
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+
+namespace wolfSSL.CSharp {
+    public class wolfssl
+    {
+        private const string wolfssl_dll = "wolfssl.dll";
+
+        /* wait for 6 seconds default on TCP socket state poll if timeout not set */
+        private const int WC_WAIT = 6000000;
+
+        /********************************
+         * Class for DTLS connections
+         */
+        /// <summary>
+        /// Contains information regarding a DTLS connection having UdpClient udp and IPEndPoint ep.
+        /// Used to keep memory alive.
+        /// </summary>
+        public class DTLS_con
+        {
+            public UdpClient udp;
+            public IPEndPoint ep;
+        }
+
+
+        /********************************
+         * Class for keeping ctx handles alive
+         */
+        [StructLayout(LayoutKind.Sequential)]
+        private class ctx_handle
+        {
+            private GCHandle rec_cb;
+            private GCHandle snd_cb;
+            private GCHandle psk_cb;
+            private GCHandle vrf_cb;
+            private IntPtr ctx;
+
+            public void set_receive(GCHandle input)
+            {
+                this.rec_cb = input;
+            }
+            public GCHandle get_receive()
+            {
+                return this.rec_cb;
+            }
+
+            public void set_send(GCHandle input)
+            {
+                this.snd_cb = input;
+            }
+            public GCHandle get_send()
+            {
+                return this.snd_cb;
+            }
+
+            public void set_psk(GCHandle input)
+            {
+                this.psk_cb = input;
+            }
+            public GCHandle get_psk()
+            {
+                return this.psk_cb;
+            }
+
+            public void set_vrf(GCHandle input)
+            {
+                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
+                {
+                    this.vrf_cb.Free();
+                }
+                this.vrf_cb = input;
+            }
+            public GCHandle get_vrf()
+            {
+                return this.vrf_cb;
+            }
+
+            public void set_ctx(IntPtr input)
+            {
+                this.ctx = input;
+            }
+            public IntPtr get_ctx()
+            {
+                return this.ctx;
+            }
+
+            /// <summary>
+            /// Called to free the pointers keeping handles alive
+            /// </summary>
+            public void free()
+            {
+                log(INFO_LOG, "freeing ctx handle");
+                if (!Object.Equals(this.rec_cb, default(GCHandle)))
+                {
+                    this.rec_cb.Free();
+                }
+                if (!Object.Equals(this.snd_cb, default(GCHandle)))
+                {
+                    this.snd_cb.Free();
+                }
+                if (!Object.Equals(this.psk_cb, default(GCHandle)))
+                {
+                    this.psk_cb.Free();
+                }
+                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
+                {
+                    this.vrf_cb.Free();
+                }
+            }
+        }
+
+        /********************************
+         * Class for keeping ssl handle alive
+         */
+        [StructLayout(LayoutKind.Sequential)]
+        private class ssl_handle
+        {
+            private GCHandle fd_pin;
+            private GCHandle psk_cb;
+            private GCHandle vrf_cb;
+            private IntPtr ssl;
+
+            public void set_fd(GCHandle input)
+            {
+                this.fd_pin = input;
+            }
+            public GCHandle get_fd()
+            {
+                return this.fd_pin;
+            }
+
+            public void set_psk(GCHandle input)
+            {
+                this.psk_cb = input;
+            }
+            public GCHandle get_psk()
+            {
+                return this.psk_cb;
+            }
+
+            public void set_vrf(GCHandle input)
+            {
+                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
+                {
+                    this.vrf_cb.Free();
+                }
+                this.vrf_cb = input;
+            }
+            public GCHandle get_vrf()
+            {
+                return this.vrf_cb;
+            }
+
+            public void set_ssl(IntPtr input)
+            {
+                this.ssl = input;
+            }
+            public IntPtr get_ssl()
+            {
+                return this.ssl;
+            }
+            public void free()
+            {
                 log(INFO_LOG, "freeing ssl handle");
 
-                if (!Object.Equals(this.fd_pin, default(GCHandle)))
-                {
-                    this.fd_pin.Free();
-                }
-                if (!Object.Equals(this.psk_cb, default(GCHandle)))
-                {
-                    this.psk_cb.Free();
-                }
-                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
-                {
-                    this.vrf_cb.Free();
-                }
-            }
-        }
-
-
-        /********************************
-         * Init wolfSSL library
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_Init();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_Cleanup();
-
-
-        /********************************
-         * Methods of connection
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfTLSv1_2_server_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfTLSv1_3_server_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSLv23_server_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfTLSv1_2_client_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfTLSv1_3_client_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSLv23_client_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfDTLSv1_2_server_method();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfDTLSv1_2_client_method();
-
-
-        /********************************
-         * Call backs
-         */
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate int CallbackIORecv_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_SetIORecv(IntPtr ctx, CallbackIORecv_delegate recv);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_SetIOReadCtx(IntPtr ssl, IntPtr rctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_GetIOReadCtx(IntPtr ssl);
-
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate int CallbackIOSend_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_SetIOSend(IntPtr ctx, CallbackIOSend_delegate send);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_SetIOWriteCtx(IntPtr ssl, IntPtr wctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_GetIOWriteCtx(IntPtr ssl);
-
-
-        /********************************
-         * CTX structure
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_CTX_new(IntPtr method);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_use_certificate_file(IntPtr ctx, string file, int type);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_load_verify_locations(IntPtr ctx, string file, string path);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_use_PrivateKey_file(IntPtr ctx, string file, int type);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_CTX_free(IntPtr ctx);
-
-
-
-        /********************************
-         * PSK
-         */
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate uint psk_delegate(IntPtr ssl, string identity, IntPtr key, uint max_sz);
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate uint psk_client_delegate(IntPtr ssl, string hint, IntPtr identity, uint id_max_len, IntPtr key, uint max_sz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_CTX_set_psk_client_callback(IntPtr ctx, psk_client_delegate psk_cb);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder identity);
-
-
-        /********************************
-         * SSL Structure
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_new(IntPtr ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_accept(IntPtr ssl);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_connect(IntPtr ssl);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_read(IntPtr ssl, IntPtr buf, int sz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_write(IntPtr ssl, IntPtr buf, int sz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_shutdown(IntPtr ssl);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_free(IntPtr ssl);
-
-
-        /********************************
-         * Cipher lists
-         */
-        /* only supports full name from cipher_name[] delimited by : */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_set_cipher_list(IntPtr ctx, StringBuilder ciphers);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_set_cipher_list(IntPtr ssl, StringBuilder ciphers);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_get_ciphers(StringBuilder ciphers, int sz);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_get_cipher(IntPtr ssl);
-        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_CIPHER_get_name(IntPtr cipher);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_get_current_cipher(IntPtr ssl);
-        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_get_version(IntPtr ssl);
-        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_get_cipher_list(IntPtr ssl);
-
-
-        /********************************
-         * Error logging
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        private extern static IntPtr wolfSSL_ERR_error_string(uint err, StringBuilder errOut);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_get_error(IntPtr ssl, int err);
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate void loggingCb(int lvl, StringBuilder msg);
+                if (!Object.Equals(this.fd_pin, default(GCHandle)))
+                {
+                    this.fd_pin.Free();
+                }
+                if (!Object.Equals(this.psk_cb, default(GCHandle)))
+                {
+                    this.psk_cb.Free();
+                }
+                if (!Object.Equals(this.vrf_cb, default(GCHandle)))
+                {
+                    this.vrf_cb.Free();
+                }
+            }
+        }
+
+
+        /********************************
+         * Init wolfSSL library
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_Init();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_Cleanup();
+
+
+        /********************************
+         * Methods of connection
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfTLSv1_2_server_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfTLSv1_3_server_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSLv23_server_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfTLSv1_2_client_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfTLSv1_3_client_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSLv23_client_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfDTLSv1_2_server_method();
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfDTLSv1_2_client_method();
+
+
+        /********************************
+         * Call backs
+         */
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate int CallbackIORecv_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_SetIORecv(IntPtr ctx, CallbackIORecv_delegate recv);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_SetIOReadCtx(IntPtr ssl, IntPtr rctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_GetIOReadCtx(IntPtr ssl);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate int CallbackIOSend_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_SetIOSend(IntPtr ctx, CallbackIOSend_delegate send);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_SetIOWriteCtx(IntPtr ssl, IntPtr wctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_GetIOWriteCtx(IntPtr ssl);
+
+
+        /********************************
+         * CTX structure
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_CTX_new(IntPtr method);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_use_certificate_file(IntPtr ctx, string file, int type);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_load_verify_locations(IntPtr ctx, string file, string path);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_use_PrivateKey_file(IntPtr ctx, string file, int type);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_CTX_free(IntPtr ctx);
+
+
+
+        /********************************
+         * PSK
+         */
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate uint psk_delegate(IntPtr ssl, string identity, IntPtr key, uint max_sz);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate uint psk_client_delegate(IntPtr ssl, string hint, IntPtr identity, uint id_max_len, IntPtr key, uint max_sz);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_CTX_set_psk_client_callback(IntPtr ctx, psk_client_delegate psk_cb);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder identity);
+
+
+        /********************************
+         * SSL Structure
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_new(IntPtr ctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_accept(IntPtr ssl);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_connect(IntPtr ssl);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_read(IntPtr ssl, IntPtr buf, int sz);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_write(IntPtr ssl, IntPtr buf, int sz);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_shutdown(IntPtr ssl);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_free(IntPtr ssl);
+
+
+        /********************************
+         * Cipher lists
+         */
+        /* only supports full name from cipher_name[] delimited by : */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_set_cipher_list(IntPtr ctx, StringBuilder ciphers);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_set_cipher_list(IntPtr ssl, StringBuilder ciphers);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_get_ciphers(StringBuilder ciphers, int sz);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_get_cipher(IntPtr ssl);
+        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_CIPHER_get_name(IntPtr cipher);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_get_current_cipher(IntPtr ssl);
+        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_get_version(IntPtr ssl);
+        [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_get_cipher_list(IntPtr ssl);
+
+
+        /********************************
+         * Error logging
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+        private extern static IntPtr wolfSSL_ERR_error_string(uint err, StringBuilder errOut);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_get_error(IntPtr ssl, int err);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void loggingCb(int lvl, StringBuilder msg);
         private static loggingCb internal_log;
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static void wolfSSL_Debugging_ON();
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_Debugging_OFF();
-
-
-        /********************************
-         * DH
-         */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_CTX_SetMinDhKey_Sz(IntPtr ctx, short size);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static int wolfSSL_SetTmpDH_file(IntPtr ssl, StringBuilder dhParam, int type);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_Debugging_OFF();
+
+
+        /********************************
+         * DH
+         */
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_CTX_SetMinDhKey_Sz(IntPtr ctx, short size);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static int wolfSSL_SetTmpDH_file(IntPtr ssl, StringBuilder dhParam, int type);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static int wolfSSL_CTX_SetTmpDH_file(IntPtr ctx, StringBuilder dhParam, int type);
 
 
-        /********************************
-         * Verify Callback
+        /********************************
+         * Verify Callback
          */
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate int CallbackVerify_delegate(int ret, IntPtr x509_ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static void wolfSSL_CTX_set_verify(IntPtr ctx, int mode, CallbackVerify_delegate vc);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate int CallbackVerify_delegate(int ret, IntPtr x509_ctx);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static void wolfSSL_CTX_set_verify(IntPtr ctx, int mode, CallbackVerify_delegate vc);
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static void wolfSSL_set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc);
 
 
-        /********************************
-         * X509 Store
+        /********************************
+         * X509 Store
          */
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_STORE_CTX_get_current_cert(IntPtr x509Ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static int wolfSSL_X509_STORE_CTX_get_error(IntPtr sk);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static IntPtr wolfSSL_X509_STORE_GetCerts(IntPtr x509Ctx);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static int wolfSSL_sk_X509_num(IntPtr sk);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
         private extern static void wolfSSL_sk_X509_free(IntPtr sk);
-        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
-        private extern static IntPtr wolfSSL_sk_X509_pop(IntPtr sk);
-
-
-        /********************************
-         * Enum types from wolfSSL library
-         */
-        public static readonly int SSL_FILETYPE_PEM = 1;
-        public static readonly int SSL_FILETYPE_ASN1 = 2;
+        [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+        private extern static IntPtr wolfSSL_sk_X509_pop(IntPtr sk);
+
+
+        /********************************
+         * Enum types from wolfSSL library
+         */
+        public static readonly int SSL_FILETYPE_PEM = 1;
+        public static readonly int SSL_FILETYPE_ASN1 = 2;
         public static readonly int SSL_FILETYPE_RAW = 3;
 
-        public static readonly int SSL_VERIFY_NONE = 0;
-        public static readonly int SSL_VERIFY_PEER = 1;
-        public static readonly int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2;
-        public static readonly int SSL_VERIFY_CLIENT_ONCE = 4;
-        public static readonly int SSL_VERIFY_POST_HANDSHAKE = 8;
-        public static readonly int SSL_VERIFY_FAIL_EXCEPT_PSK = 16;
-
-        public static readonly int CBIO_ERR_GENERAL = -1;
-        public static readonly int CBIO_ERR_WANT_READ = -2;
-        public static readonly int CBIO_ERR_WANT_WRITE = -2;
-        public static readonly int CBIO_ERR_CONN_RST = -3;
-        public static readonly int CBIO_ERR_ISR = -4;
-        public static readonly int CBIO_ERR_CONN_CLOSE = -5;
-        public static readonly int CBIO_ERR_TIMEOUT = -6;
-
-        public static readonly int ERROR_LOG = 0;
-        public static readonly int INFO_LOG = 1;
-        public static readonly int ENTER_LOG = 2;
-        public static readonly int LEAVE_LOG = 3;
-        public static readonly int OTHER_LOG = 4;
-
-        public static readonly int SUCCESS = 1;
-        public static readonly int FAILURE = 0;
-
-
-        private static IntPtr unwrap_ctx(IntPtr ctx)
-        {
-            try {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-                return handles.get_ctx();
-            } catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx pointer is incorrect " + e);
-                return IntPtr.Zero;
-            }
-        }
-        private static IntPtr unwrap_ssl(IntPtr ssl)
-        {
-            try {
-                GCHandle gch = GCHandle.FromIntPtr(ssl);
-                ssl_handle handles = (ssl_handle)gch.Target;
-                return handles.get_ssl();
-            } catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl pointer is incorrect " + e);
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Call back to allow receiving TLS information
-        /// </summary>
-        /// <param name="ssl">structure of ssl passed in</param>
-        /// <param name="buf">buffer to contain received msg</param>
-        /// <param name="sz">size of buffer</param>
-        /// <param name="ctx">optional information passed in</param>
-        /// <returns>size of message received</returns>
-        private static int wolfSSLCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
-        {
-            if (sz <= 0)
-            {
-                log(ERROR_LOG, "wolfssl receive error, size less than 0");
-                return wolfssl.CBIO_ERR_GENERAL;
-            }
-
-            int amtRecv = 0;
-
-            try
-            {
-                System.Runtime.InteropServices.GCHandle gch;
-                gch = GCHandle.FromIntPtr(ctx);
-                Socket con = (System.Net.Sockets.Socket)gch.Target;
-                Byte[] msg = new Byte[sz];
-                amtRecv = con.Receive(msg, msg.Length, 0);
-                if (amtRecv == 0)
-                {
-                    /* No data received so check for a response to see if connection is still open */
-                    if (con.Poll((con.ReceiveTimeout > 0) ? con.ReceiveTimeout : WC_WAIT, SelectMode.SelectRead))
-                    {
-                        log(ERROR_LOG, "socket connection issue, suspected connection termination.");
-                        return wolfssl.CBIO_ERR_CONN_CLOSE;
-                    }
-                }
-                Marshal.Copy(msg, 0, buf, sz);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "Error in receive " + e.ToString());
-                return wolfssl.CBIO_ERR_CONN_CLOSE;
-            }
-
-            return amtRecv;
-        }
-
-
-        /// <summary>
-        /// Call back used for sending TLS information
-        /// </summary>
-        /// <param name="ssl">pointer to ssl struct</param>
-        /// <param name="buf">buffer containing information to send</param>
-        /// <param name="sz">size of buffer to send</param>
-        /// <param name="ctx">optional information</param>
-        /// <returns>amount of information sent</returns>
-        private static int wolfSSLCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
-        {
-            if (sz <= 0)
-            {
-                log(ERROR_LOG, "wolfssl send error, size less than 0");
-                return wolfssl.CBIO_ERR_GENERAL;
-            }
-
-            try
-            {
-                System.Runtime.InteropServices.GCHandle gch;
-                gch = GCHandle.FromIntPtr(ctx);
-
-                Socket con = (System.Net.Sockets.Socket)gch.Target;
-                Byte[] msg = new Byte[sz];
-                Marshal.Copy(buf, msg, 0, sz);
-                if (con.Send(msg, 0, msg.Length, SocketFlags.None) == 0 && sz != 0)
-                {
-                    /* no data sent and msg size is larger then 0, check for lost connection */
-                    if (con.Poll((con.SendTimeout > 0) ? con.SendTimeout : WC_WAIT, SelectMode.SelectWrite))
-                    {
-                        log(ERROR_LOG, "socket connection issue, suspect connection termination");
-                        return wolfssl.CBIO_ERR_CONN_CLOSE;
-                    }
-                }
-                return sz;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "socket connection issue " + e.ToString());
-                return wolfssl.CBIO_ERR_CONN_CLOSE;
-            }
-        }
-
-
-        /// <summary>
-        /// Call back used for sending DTLS information
-        /// </summary>
-        /// <param name="ssl">pointer to ssl struct</param>
-        /// <param name="buf">buffer containing information to send</param>
-        /// <param name="sz">size of buffer to send</param>
-        /// <param name="ctx">optional information</param>
-        /// <returns>amount of information sent</returns>
-        private static int wolfSSL_dtlsCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
-        {
-            if (sz <= 0)
-            {
-                log(ERROR_LOG, "wolfssl dtls send error, size less than 0");
-                return wolfssl.CBIO_ERR_GENERAL;
-            }
-
-            try
-            {
-                System.Runtime.InteropServices.GCHandle gch;
-                gch = GCHandle.FromIntPtr(ctx);
-
-                DTLS_con con = (DTLS_con)gch.Target;
-
-                Byte[] msg = new Byte[sz];
-                Marshal.Copy(buf, msg, 0, sz);
-                con.udp.Send(msg, msg.Length, con.ep);
-                return msg.Length;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "socket connection issue " + e.ToString());
-                return wolfssl.CBIO_ERR_CONN_CLOSE;
-            }
-        }
-
-
-        /// <summary>
-        /// Call back to allow receiving DTLS information
-        /// </summary>
-        /// <param name="ssl">structure of ssl passed in</param>
-        /// <param name="buf">buffer to contain received msg</param>
-        /// <param name="sz">size of buffer</param>
-        /// <param name="ctx">optional information passed in</param>
-        /// <returns>size of message received</returns>
-        private static int wolfSSL_dtlsCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
-        {
-            if (sz <= 0)
-            {
-                log(ERROR_LOG, "wolfssl dtls receive error, size less than 0");
-                return wolfssl.CBIO_ERR_GENERAL;
-            }
-
-            try
-            {
-                System.Runtime.InteropServices.GCHandle gch;
-                gch = GCHandle.FromIntPtr(ctx);
-                DTLS_con con = (DTLS_con)gch.Target;
-
-                Byte[] msg = con.udp.Receive(ref con.ep);
-                if (msg.Length > sz)
-                {
-                    log(ERROR_LOG, "wolfssl DTLS packet received was larger than buffer");
-                    return wolfssl.CBIO_ERR_GENERAL;
-                }
-
-                Marshal.Copy(msg, 0, buf, msg.Length);
-                return msg.Length;
-            }
-            catch (Exception e)
-            {
-                /* issue with receive or size of buffer */
-                log(ERROR_LOG, "socket read issue " + e.ToString());
-                return wolfssl.CBIO_ERR_CONN_CLOSE;
-            }
-        }
-
-
-        /// <summary>
-        /// Create a new ssl structure
-        /// </summary>
-        /// <param name="ctx">structure to create ssl structure from</param>
-        /// <returns>pointer to ssl structure</returns>
-        public static IntPtr new_ssl(IntPtr ctx)
-        {
-            if (ctx == IntPtr.Zero)
-                return IntPtr.Zero;
-
-            try
-            {
-                ssl_handle io;
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "new_ssl ctx unwrap error");
-                    return IntPtr.Zero;
-                }
-
-                io = new ssl_handle();
-                io.set_ssl(wolfSSL_new(local_ctx));
-
-                /* check if null */
-                if (io.get_ssl() == IntPtr.Zero)
-                {
-                    return IntPtr.Zero;
-                }
-
-                /* keep memory pinned to be able to reference by address */
-                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Used for a server to accept a connection
-        /// </summary>
-        /// <param name="ssl">structure containing info for connection</param>
-        /// <returns>1 on success</returns>
-        public static int accept(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "accept ssl unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_accept(sslCtx);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "accept error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Used for a client to connect
-        /// </summary>
-        /// <param name="ssl">structure containing connection info</param>
-        /// <returns>1 on success</returns>
-        public static int connect(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "connect ssl unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_connect(sslCtx);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "connect error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Read message from secure connection
-        /// </summary>
-        /// <param name="ssl">structure containing info about connection</param>
-        /// <param name="buf">object to hold incoming message (Unicode format)</param>
-        /// <param name="sz">size of available memory in buf</param>
-        /// <returns>amount of data read on success</returns>
-        public static int read(IntPtr ssl, StringBuilder buf, int sz)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                IntPtr data;
-                int ret;
-                byte[] msg;
-
-                buf.Clear(); /* Clear incomming buffer */
-
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "read ssl unwrap error");
-                    return FAILURE;
-                }
-                data = Marshal.AllocHGlobal(sz);
-
-                ret = wolfSSL_read(sslCtx, data, sz);
-
-                if (ret >= 0)
-                {
-                    /* Get data that was sent across and store it using a literal read of
-                     * the conversion from bytes to character. Takes care of if
-                     * a null terminator is part of the message read.
-                     */
-                    msg = new byte[ret];
-                    Marshal.Copy(data, msg, 0, ret);
-                    for (int i = 0; i < ret; i++)
-                    {
-                        buf.Append(@Convert.ToChar(msg[i]));
-                    }
-                }
-                Marshal.FreeHGlobal(data);
-
-                return ret;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl read error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Read message from secure connection using a byte array
-        /// </summary>
-        /// <param name="ssl">structure containing info about connection</param>
-        /// <param name="buf">object to hold incoming message (raw bytes)</param>
-        /// <param name="sz">size of available memory in buf</param>
-        /// <returns>amount of data read on success</returns>
-        public static int read(IntPtr ssl, byte[] buf, int sz)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                IntPtr data;
-                int ret;
-
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "read ssl unwrap error");
-                    return FAILURE;
-                }
-                data = Marshal.AllocHGlobal(sz);
-
-                ret = wolfSSL_read(sslCtx, data, sz);
-
-                if (ret >= 0)
-                {
-                    Marshal.Copy(data, buf, 0, ret);
-                }
-                Marshal.FreeHGlobal(data);
-
-                return ret;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl read error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-
-        /// <summary>
-        /// Write message to secure connection
-        /// </summary>
-        /// <param name="ssl">structure containing connection info</param>
-        /// <param name="buf">message to send</param>
-        /// <param name="sz">size of the message</param>
-        /// <returns>amount sent on success</returns>
-        public static int write(IntPtr ssl, StringBuilder buf, int sz)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                IntPtr data;
-                int ret;
-
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "write ssl unwrap error");
-                    return FAILURE;
-                }
-
-                data = Marshal.AllocHGlobal(sz);
-                Marshal.Copy(System.Text.Encoding.Default.GetBytes(buf.ToString()), 0,
-                       data, System.Text.Encoding.Default.GetByteCount(buf.ToString()));
-                ret = wolfSSL_write(sslCtx, data, sz);
-                Marshal.FreeHGlobal(data);
-                return ret;
-
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl write error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Write message to secure connection
-        /// </summary>
-        /// <param name="ssl">structure containing connection info</param>
-        /// <param name="buf">message to send</param>
-        /// <param name="sz">size of the message</param>
-        /// <returns>amount sent on success</returns>
-        public static int write(IntPtr ssl, byte[] buf, int sz)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                IntPtr data;
-                int ret;
-
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "write ssl unwrap error");
-                    return FAILURE;
-                }
-                data = Marshal.AllocHGlobal(sz);
-                Marshal.Copy(buf, 0, data, sz);
-                ret = wolfSSL_write(sslCtx, data, sz);
-                Marshal.FreeHGlobal(data);
-                return ret;
-
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl write error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Free information stored in ssl struct
-        /// </summary>
-        /// <param name="ssl">pointer to ssl struct to free</param>
-        public static void free(IntPtr ssl)
-        {
-            try
-            {
-                IntPtr sslCtx;
-                GCHandle gch = GCHandle.FromIntPtr(ssl);
-                ssl_handle handles = (ssl_handle)gch.Target;
-
-                sslCtx = handles.get_ssl();
-                wolfSSL_free(sslCtx);
-                handles.free();
-                gch.Free();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl free error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Shutdown a connection
-        /// </summary>
-        /// <param name="ssl">pointer to ssl struct to close connection of</param>
-        /// <returns>1 on success</returns>
-        public static int shutdown(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return FAILURE;
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "shutdown ssl unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_shutdown(sslCtx);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl shutdwon error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Optional, can be used to set a custom receive function
-        /// </summary>
-        /// <param name="ctx">structure to set receive function in</param>
-        /// <param name="func">function to use when reading socket</param>
-        public static void SetIORecv(IntPtr ctx, CallbackIORecv_delegate func)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-
-                /* check if already stored handle needs freed */
-                gch = handles.get_receive();
-                if (!Object.Equals(gch, default(GCHandle)))
-                {
-                    gch.Free();
-                }
-
-                /* keep new function alive */
-                handles.set_receive(GCHandle.Alloc(func));
-
-                wolfSSL_CTX_SetIORecv(handles.get_ctx(), func);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl setIORecv error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Optional, can be used to set a custom send function
-        /// </summary>
-        /// <param name="ctx">structure to set function in</param>
-        /// <param name="func">function to use when sending data</param>
-        public static void SetIOSend(IntPtr ctx, CallbackIOSend_delegate func)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-
-                /* check if already stored handle needs freed */
-                gch = handles.get_send();
-                if (!Object.Equals(gch, default(GCHandle)))
-                {
-                    gch.Free();
-                }
-
-                /* keep new function alive */
-                handles.set_send(GCHandle.Alloc(func));
-
-                wolfSSL_CTX_SetIOSend(handles.get_ctx(), func);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl setIOSend error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Create a new CTX structure
-        /// </summary>
-        /// <param name="method">method to use such as TLSv1.2</param>
-        /// <returns>pointer to CTX structure</returns>
-        public static IntPtr CTX_new(IntPtr method)
-        {
-            try
-            {
-                IntPtr ctx = wolfSSL_CTX_new(method);
-                if (ctx == IntPtr.Zero)
-                    return ctx;
-
-                ctx_handle io = new ctx_handle();
-                io.set_ctx(ctx);
-
-                CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSLCbIORecv);
-                io.set_receive(GCHandle.Alloc(recv));
-                wolfSSL_CTX_SetIORecv(ctx, recv);
-
-                CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSLCbIOSend);
-                io.set_send(GCHandle.Alloc(send));
-                wolfSSL_CTX_SetIOSend(ctx, send);
-
-                /* keep memory pinned */
-                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "ctx_new error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Create a new CTX structure for a DTLS connection
-        /// </summary>
-        /// <param name="method">Method to use in connection ie DTLSv1.2</param>
-        /// <returns></returns>
-        public static IntPtr CTX_dtls_new(IntPtr method)
-        {
-            try
-            {
-                IntPtr ctx = wolfSSL_CTX_new(method);
-                if (ctx == IntPtr.Zero)
-                    return ctx;
-
-                ctx_handle io = new ctx_handle();
-                io.set_ctx(ctx);
-
-                CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSL_dtlsCbIORecv);
-                io.set_receive(GCHandle.Alloc(recv));
-                wolfSSL_CTX_SetIORecv(ctx, recv);
-
-                CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSL_dtlsCbIOSend);
-                io.set_send(GCHandle.Alloc(send));
-                wolfSSL_CTX_SetIOSend(ctx, send);
-
-                /* keep memory pinned */
-                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "ctx_dtls_new error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Free information used in CTX structure
-        /// </summary>
-        /// <param name="ctx">structure to free</param>
-        public static void CTX_free(IntPtr ctx)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-                wolfSSL_CTX_free(handles.get_ctx());
-                handles.free();
-                gch.Free();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx free error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Set identity hint to use
-        /// </summary>
-        /// <param name="ctx">pointer to structure of ctx to set hint in</param>
-        /// <param name="hint">hint to use</param>
-        /// <returns>1 on success</returns>
-        public static int CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder hint)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX use psk identity hint unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_use_psk_identity_hint(local_ctx, hint);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl psk identity hint error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Set the function to use for PSK connections
-        /// </summary>
-        /// <param name="ctx">pointer to CTX that the function is set in</param>
-        /// <param name="psk_cb">PSK function to use</param>
-        public static void CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-
-                handles.set_psk(GCHandle.Alloc(psk_cb));
-                wolfSSL_CTX_set_psk_server_callback(handles.get_ctx(), psk_cb);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl psk server callback error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Set the function to use for PSK connections
-        /// </summary>
-        /// <param name="ctx">pointer to CTX that the function is set in</param>
-        /// <param name="psk_cb">PSK function to use</param>
-        public static void CTX_set_psk_client_callback(IntPtr ctx, psk_client_delegate psk_cb)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ctx);
-                ctx_handle handles = (ctx_handle)gch.Target;
-
-                handles.set_psk(GCHandle.Alloc(psk_cb));
-                wolfSSL_CTX_set_psk_client_callback(handles.get_ctx(), psk_cb);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl psk client callback error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Set the function to use for PSK connections on a single TLS/DTLS connection
-        /// </summary>
-        /// <param name="ctx">pointer to SSL that the function is set in</param>
-        /// <param name="psk_cb">PSK function to use</param>
-        public static void set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb)
-        {
-            try
-            {
-                GCHandle gch = GCHandle.FromIntPtr(ssl);
-                ssl_handle handles = (ssl_handle)gch.Target;
-
-                handles.set_psk(GCHandle.Alloc(psk_cb));
-                wolfSSL_set_psk_server_callback(handles.get_ssl(), psk_cb);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl psk server callback error " + e.ToString());
-            }
-        }
-
-
-        /// <summary>
-        /// Set Socket for TLS connection
-        /// </summary>
-        /// <param name="ssl">structure to set Socket in</param>
-        /// <param name="fd">Socket to use</param>
-        /// <returns>1 on success</returns>
-        public static int set_fd(IntPtr ssl, Socket fd)
-        {
-            /* sanity check on inputs */
-            if (ssl == IntPtr.Zero)
-            {
-                return FAILURE;
-            }
-
-            try
-            {
-                if (!fd.Equals(null))
-                {
-                    GCHandle gch = GCHandle.FromIntPtr(ssl);
-                    ssl_handle handles = (ssl_handle)gch.Target;
-                    IntPtr sslCtx = handles.get_ssl();
-                    IntPtr ptr;
-                    GCHandle fd_pin = GCHandle.Alloc(fd);
-
-                    if (sslCtx == IntPtr.Zero)
-                    {
-                        log(ERROR_LOG, "wolfssl error setting up fd!!");
-                        return FAILURE;
-                    }
-
-                    handles.set_fd(fd_pin);
-                    ptr = GCHandle.ToIntPtr(fd_pin);
-                    wolfSSL_SetIOWriteCtx(sslCtx, ptr); //pass along the socket for writing to
-                    wolfSSL_SetIOReadCtx(sslCtx, ptr); //pass along the socket for reading from
-
-                    return SUCCESS;
-                }
-
-                return FAILURE;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "Error setting up fd!! " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Get socket of a TLS connection
-        /// </summary>
-        /// <param name="ssl">structure to get socket from</param>
-        /// <returns>Socket object used for connection</returns>
-        public static Socket get_fd(IntPtr ssl)
-        {
-            try
-            {
-                IntPtr ptr;
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl get_fd error");
-                    return null;
-                }
-
-                ptr = wolfSSL_GetIOReadCtx(sslCtx);
-                if (ptr != IntPtr.Zero)
-                {
-                    GCHandle gch = GCHandle.FromIntPtr(ptr);
-                    return (System.Net.Sockets.Socket)gch.Target;
-                }
-                return null;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get_fd error " + e.ToString());
-                return null;
-            }
-        }
-
-
-
-        /// <summary>
-        /// Set information needed to send and receive a DTLS connection
-        /// </summary>
-        /// <param name="ssl">structure to set information in</param>
-        /// <param name="udp">UDP object to send and receive</param>
-        /// <param name="ep">End point of connection</param>
-        /// <returns>1 on success</returns>
-        public static int set_dtls_fd(IntPtr ssl, UdpClient udp, IPEndPoint ep)
-        {
-            /* sanity check on inputs */
-            if (ssl == IntPtr.Zero)
-            {
-                return FAILURE;
-            }
-
-            try
-            {
-                if (!udp.Equals(null) && !ep.Equals(null))
-                {
-                    IntPtr ptr;
-                    DTLS_con con;
-                    GCHandle gch = GCHandle.FromIntPtr(ssl);
-                    ssl_handle handles = (ssl_handle)gch.Target;
-                    GCHandle fd_pin;
-
-                    con = new DTLS_con();
-                    con.udp = udp;
-                    con.ep = ep;
-                    fd_pin = GCHandle.Alloc(con);
-                    handles.set_fd(fd_pin);
-                    ptr = GCHandle.ToIntPtr(fd_pin);
-                    wolfSSL_SetIOWriteCtx(handles.get_ssl(), ptr); //pass along the socket for writing to
-                    wolfSSL_SetIOReadCtx(handles.get_ssl(), ptr); //pass along the socket for reading from
-
-                    return SUCCESS;
-                }
-                return FAILURE;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "Error setting up fd!! " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Get the pointer to DTLS_con class used for connection
-        /// </summary>
-        /// <param name="ssl">structure to get connection from</param>
-        /// <returns>DTLS_con object</returns>
-        public static DTLS_con get_dtls_fd(IntPtr ssl)
-        {
-            try
-            {
-                IntPtr ptr;
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl get_dtls_fd error");
-                    return null;
-                }
-
-                ptr = wolfSSL_GetIOReadCtx(sslCtx);
-                if (ptr != IntPtr.Zero)
-                {
-                    GCHandle gch = GCHandle.FromIntPtr(ptr);
-                    return (DTLS_con)gch.Target;
-                }
-                return null;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get_dtls_fd error " + e.ToString());
-                return null;
-            }
-        }
-
-
-        /// <summary>
-        /// Get available cipher suites
-        /// </summary>
-        /// <param name="list">list to fill with cipher suite names</param>
-        /// <param name="sz">size of list available to fill</param>
-        /// <returns>1 on success</returns>
-        public static int get_ciphers(StringBuilder list, int sz)
-        {
-            try
-            {
-                return wolfSSL_get_ciphers(list, sz);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get_ciphers error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Initialize wolfSSL library
-        /// </summary>
-        /// <returns>1 on success</returns>
-        public static int Init()
-        {
-            try
-            {
-                return wolfSSL_Init();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl init error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Clean up wolfSSL library memory
-        /// </summary>
-        /// <returns>1 on success</returns>
-        public static int Cleanup()
-        {
-            try
-            {
-                return wolfSSL_Cleanup();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl cleanup error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Set up TLS version 1.2 method
-        /// </summary>
-        /// <returns>pointer to TLSv1.2 method</returns>
-        public static IntPtr useTLSv1_2_server()
-        {
-            try
-            {
-                return wolfTLSv1_2_server_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-        /// <summary>
-        /// Set up TLS version 1.3 method
-        /// </summary>
-        /// <returns>pointer to TLSv1.3 method</returns>
-        public static IntPtr useTLSv1_3_server()
-        {
-            try
-            {
-                return wolfTLSv1_3_server_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Use any TLS version
-        /// </summary>
-        /// <returns>pointer to method</returns>
-        public static IntPtr usev23_server()
-        {
-            try
-            {
-                return wolfSSLv23_server_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Set up TLS version 1.2 method
-        /// </summary>
-        /// <returns>pointer to TLSv1.2 method</returns>
-        public static IntPtr useTLSv1_2_client()
-        {
-            try
-            {
-                return wolfTLSv1_2_client_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-        /// <summary>
-        /// Set up TLS version 1.3 method
-        /// </summary>
-        /// <returns>pointer to TLSv1.3 method</returns>
-        public static IntPtr useTLSv1_3_client()
-        {
-            try
-            {
-                return wolfTLSv1_3_client_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-        /// <summary>
-        /// Use any TLS version
-        /// </summary>
-        /// <returns>pointer to method</returns>
-        public static IntPtr usev23_client()
-        {
-            try
-            {
-                return wolfSSLv23_client_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Set up DTLS version 1.2
-        /// </summary>
-        /// <returns>pointer to DTLSv1.2 method</returns>
-        public static IntPtr useDTLSv1_2_server()
-        {
-            try
-            {
-                return wolfDTLSv1_2_server_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Set up DTLS version 1.2
-        /// </summary>
-        /// <returns>pointer to DTLSv1.2 method</returns>
-        public static IntPtr useDTLSv1_2_client()
-        {
-            try
-            {
-                return wolfDTLSv1_2_client_method();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl error " + e.ToString());
-                return IntPtr.Zero;
-            }
-        }
-
-
-        /// <summary>
-        /// Gets the current cipher suite being used in connection
-        /// </summary>
-        /// <param name="ssl">SSL struct to get cipher suite from</param>
-        /// <returns>string containing current cipher suite</returns>
-        public static string get_current_cipher(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return null;
-            try
-            {
-                IntPtr ssl_cipher;
-                IntPtr ssl_cipher_ptr;
-                string ssl_cipher_str;
-
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl get_current_cipher error");
-                    return null;
-                }
-
-                ssl_cipher = wolfSSL_get_current_cipher(sslCtx);
-                ssl_cipher_ptr = wolfSSL_CIPHER_get_name(ssl_cipher);
-                ssl_cipher_str = Marshal.PtrToStringAnsi(ssl_cipher_ptr);
-
-                return ssl_cipher_str;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get current cipher error " + e.ToString());
-                return null;
-            }
-        }
-
-
-        /// <summary>
-        /// Set available cipher suites for all ssl structs created from ctx
-        /// </summary>
-        /// <param name="ctx">CTX structure to set</param>
-        /// <param name="list">List full of ciphers suites</param>
-        /// <returns>1 on success</returns>
-        public static int CTX_set_cipher_list(IntPtr ctx, StringBuilder list)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX set cipher list error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_set_cipher_list(local_ctx, list);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx set cipher list error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Set available cipher suite in local connection
-        /// </summary>
-        /// <param name="ssl">Structure to set cipher suite in</param>
-        /// <param name="list">List of cipher suites</param>
-        /// <returns>1 on success</returns>
-        public static int set_cipher_list(IntPtr ssl, StringBuilder list)
-        {
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl set_cipher_list error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_set_cipher_list(sslCtx, list);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl set cipher error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Gets the version of the connection made ie TLSv1.2
-        /// </summary>
-        /// <param name="ssl">SSL struct to get version of</param>
-        /// <returns>string containing version</returns>
-        public static string get_version(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return null;
-
-            try
-            {
-                IntPtr version_ptr;
-                string version;
-
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl get_version error");
-                    return null;
-                }
-
-                version_ptr = wolfSSL_get_version(sslCtx);
-                version = Marshal.PtrToStringAnsi(version_ptr);
-
-                return version;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get version error " + e.ToString());
-                return null;
-            }
-        }
-
-
-        /// <summary>
-        /// Get a string containing error value and reason
-        /// </summary>
-        /// <param name="ssl">SSL struct that had error</param>
-        /// <returns>String containing error value and reason</returns>
-        public static string get_error(IntPtr ssl)
-        {
-            if (ssl == IntPtr.Zero)
-                return null;
-
-            try
-            {
-                int err;
-                StringBuilder err_name;
-                StringBuilder ret;
-
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "wolfssl get_error error");
-                    return null;
-                }
-
-                /* wolfSSL max error length is 80 */
-                ret = new StringBuilder(' ', 100);
-                err = wolfSSL_get_error(sslCtx, 0);
-                err_name = new StringBuilder(new String(' ', 80));
-                wolfSSL_ERR_error_string((uint)err, err_name);
-                ret.Append("Error " + err + " " + err_name.ToString());
-
-                return ret.ToString();
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl get error, error " + e.ToString());
-                return null;
-            }
-        }
-
-
-        /// <summary>
-        /// Used to load in the certificate file
-        /// </summary>
-        /// <param name="ctx">CTX structure for TLS/SSL connections</param>
-        /// <param name="fileCert">Name of the file to load including absolute path</param>
-        /// <param name="type">Type of file ie PEM or DER</param>
-        /// <returns>1 on success</returns>
-        public static int CTX_use_certificate_file(IntPtr ctx, string fileCert, int type)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX use certificate file error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_use_certificate_file(local_ctx, fileCert, type);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx use cert file error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Used to load in the peer trusted root file
-        /// </summary>
-        /// <param name="ctx">CTX structure for TLS/SSL connections</param>
-        /// <param name="fileCert">Name of the file to load including absolute path</param>
-        /// <param name="type">path to multiple certificates (try to load all in path) </param>
-        /// <returns>1 on success</returns>
-        public static int CTX_load_verify_locations(IntPtr ctx, string fileCert, string path)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX load verify locations certificate file error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_load_verify_locations(local_ctx, fileCert, path);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx load verify locations file error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-        /// <summary>
-        /// Used to load in the private key from a file 
-        /// </summary>
-        /// <param name="ctx">CTX structure for TLS/SSL connections </param>
-        /// <param name="fileKey">Name of the file, includeing absolute directory</param>
-        /// <param name="type">Type of file ie PEM or DER</param>
-        /// <returns>1 on success</returns>
-        public static int CTX_use_PrivateKey_file(IntPtr ctx, string fileKey, int type)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX use PrivateKey file error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_use_PrivateKey_file(local_ctx, fileKey, type);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx use key file error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Set temporary DH parameters
-        /// </summary>
-        /// <param name="ssl">Structure to set in</param>
-        /// <param name="dhparam">file name</param>
-        /// <param name="file_type">type of file ie PEM</param>
-        /// <returns>1 on success</returns>
-        public static int SetTmpDH_file(IntPtr ssl, StringBuilder dhparam, int file_type)
-        {
-            try
-            {
-                IntPtr sslCtx = unwrap_ssl(ssl);
-                if (sslCtx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "SetTmpDH_file ssl unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_SetTmpDH_file(sslCtx, dhparam, file_type);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "SetTmpDH_file error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-        /// <summary>
-        /// Set temporary DH parameters
-        /// </summary>
-        /// <param name="ctx">Structure to set in</param>
-        /// <param name="dhparam">file name</param>
-        /// <param name="file_type">type of file ie PEM</param>
-        /// <returns>1 on success</returns>
-        public static int CTX_SetTmpDH_file(IntPtr ctx, StringBuilder dhparam, int file_type)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX_SetTmpDH_file ctx unwrap error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_SetTmpDH_file(local_ctx, dhparam, file_type);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "CTX_SetTmpDH_file error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-
-        /// <summary>
-        /// Used to set the minimum size of DH key
-        /// </summary>
-        /// <param name="ctx">Structure to store key size</param>
-        /// <param name="minDhKey">Min key size </param>
-        /// <returns>1 on success</returns>
-        public static int CTX_SetMinDhKey_Sz(IntPtr ctx, short minDhKey)
-        {
-            try
-            {
-                IntPtr local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX SetMinDhKey_Sz error");
-                    return FAILURE;
-                }
-
-                return wolfSSL_CTX_SetMinDhKey_Sz(local_ctx, minDhKey);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx set min dh key error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-        /// <summary>
-        /// Set the certificate verification mode and optional callback function
-        /// </summary>
-        /// <param name="ctx">pointer to CTX that the function is set in</param>
-        /// <param name="mode">See SSL_VERIFY options</param>
-        /// <param name="vc">Optional verify callback function to use</param>
-        public static int CTX_set_verify(IntPtr ctx, int mode, CallbackVerify_delegate vc)
-        {
-            try
-            {
-                GCHandle   gch;
-                ctx_handle handles;
-                IntPtr     local_ctx = unwrap_ctx(ctx);
-                if (local_ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "CTX set_verify error");
-                    return FAILURE;
-                }
-
-                /* pin the verify callback to protect from garbage collection */
-                if (!vc.Equals(null)) {
-                    gch = GCHandle.FromIntPtr(ctx);
-                    handles = (ctx_handle)gch.Target;
-                    handles.set_vrf(GCHandle.Alloc(vc));
-                }
-
-                wolfSSL_CTX_set_verify(local_ctx, mode, vc);
-                return SUCCESS;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl ctx set verify error " + e.ToString());
-                return FAILURE;
-            }
-        }
-
-        /// <summary>
-        /// Set the certificate verification mode and optional callback function
-        /// </summary>
-        /// <param name="ctx">pointer to SSL object that the function is set in</param>
-        /// <param name="mode">See SSL_VERIFY options</param>
-        /// <param name="vc">Optional verify callback function to use</param>
-        public static int set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc)
-        {
-            try
-            {
-                GCHandle   gch;
-                ssl_handle handles;
-                IntPtr     local_ssl = unwrap_ssl(ssl);
-                if (local_ssl == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "set_verify error");
-                    return FAILURE;
-                }
-
-                /* pin the verify callback to protect from garbage collection */
-                if (!vc.Equals(null)) {
-                    gch = GCHandle.FromIntPtr(ssl);
-                    handles = (ssl_handle)gch.Target;
-                    handles.set_vrf(GCHandle.Alloc(vc));
-                }
-
-                wolfSSL_set_verify(local_ssl, mode, vc);
-                return SUCCESS;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl set verify error " + e.ToString());
-                return FAILURE;
-            }
+        public static readonly int SSL_VERIFY_NONE = 0;
+        public static readonly int SSL_VERIFY_PEER = 1;
+        public static readonly int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2;
+        public static readonly int SSL_VERIFY_CLIENT_ONCE = 4;
+        public static readonly int SSL_VERIFY_POST_HANDSHAKE = 8;
+        public static readonly int SSL_VERIFY_FAIL_EXCEPT_PSK = 16;
+
+        public static readonly int CBIO_ERR_GENERAL = -1;
+        public static readonly int CBIO_ERR_WANT_READ = -2;
+        public static readonly int CBIO_ERR_WANT_WRITE = -2;
+        public static readonly int CBIO_ERR_CONN_RST = -3;
+        public static readonly int CBIO_ERR_ISR = -4;
+        public static readonly int CBIO_ERR_CONN_CLOSE = -5;
+        public static readonly int CBIO_ERR_TIMEOUT = -6;
+
+        public static readonly int ERROR_LOG = 0;
+        public static readonly int INFO_LOG = 1;
+        public static readonly int ENTER_LOG = 2;
+        public static readonly int LEAVE_LOG = 3;
+        public static readonly int OTHER_LOG = 4;
+
+        public static readonly int SUCCESS = 1;
+        public static readonly int FAILURE = 0;
+
+
+        private static IntPtr unwrap_ctx(IntPtr ctx)
+        {
+            try {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+                return handles.get_ctx();
+            } catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx pointer is incorrect " + e);
+                return IntPtr.Zero;
+            }
+        }
+        private static IntPtr unwrap_ssl(IntPtr ssl)
+        {
+            try {
+                GCHandle gch = GCHandle.FromIntPtr(ssl);
+                ssl_handle handles = (ssl_handle)gch.Target;
+                return handles.get_ssl();
+            } catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl pointer is incorrect " + e);
+                return IntPtr.Zero;
+            }
         }
 
 
-        /// <summary>
-        /// Set the certificate verification mode and optional callback function
-        /// </summary>
-        /// <param name="ctx">pointer to SSL object that the function is set in</param>
-        /// <param name="mode">See SSL_VERIFY options</param>
-        /// <param name="vc">Optional verify callback function to use</param>
-        public static X509 X509_STORE_CTX_get_current_cert(IntPtr x509Ctx)
-        {
-            X509 ret = null;
-            try
-            {
-                if (x509Ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "pointer passed in was not set");
-                    return ret;
-                }
-                IntPtr x509 = wolfSSL_X509_STORE_CTX_get_current_cert(x509Ctx);
-                if (x509 != IntPtr.Zero) {
-                    return new X509(x509, false);
-                }
-                return ret;
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
-                return ret;
-            }
+        /// <summary>
+        /// Call back to allow receiving TLS information
+        /// </summary>
+        /// <param name="ssl">structure of ssl passed in</param>
+        /// <param name="buf">buffer to contain received msg</param>
+        /// <param name="sz">size of buffer</param>
+        /// <param name="ctx">optional information passed in</param>
+        /// <returns>size of message received</returns>
+        private static int wolfSSLCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+        {
+            if (sz <= 0)
+            {
+                log(ERROR_LOG, "wolfssl receive error, size less than 0");
+                return wolfssl.CBIO_ERR_GENERAL;
+            }
+
+            int amtRecv = 0;
+
+            try
+            {
+                System.Runtime.InteropServices.GCHandle gch;
+                gch = GCHandle.FromIntPtr(ctx);
+                Socket con = (System.Net.Sockets.Socket)gch.Target;
+                Byte[] msg = new Byte[sz];
+                amtRecv = con.Receive(msg, msg.Length, 0);
+                if (amtRecv == 0)
+                {
+                    /* No data received so check for a response to see if connection is still open */
+                    if (con.Poll((con.ReceiveTimeout > 0) ? con.ReceiveTimeout : WC_WAIT, SelectMode.SelectRead))
+                    {
+                        log(ERROR_LOG, "socket connection issue, suspected connection termination.");
+                        return wolfssl.CBIO_ERR_CONN_CLOSE;
+                    }
+                }
+                Marshal.Copy(msg, 0, buf, sz);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "Error in receive " + e.ToString());
+                return wolfssl.CBIO_ERR_CONN_CLOSE;
+            }
+
+            return amtRecv;
         }
 
 
-        /// <summary>
-        /// Gets all of the certificates from store
-        /// </summary>
-        /// <param name="x509Ctx">pointer to store to get certificates from</param>
-        public static X509[] X509_STORE_CTX_get_certs(IntPtr x509Ctx)
-        {
-            X509[] ret = null;
-            try
-            {
-                if (x509Ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "pointer passed in was not set");
-                    return ret;
-                }
-                IntPtr sk = wolfSSL_X509_STORE_GetCerts(x509Ctx);
-                if (sk != IntPtr.Zero) {
-                    int i;
-                    int numCerts = wolfSSL_sk_X509_num(sk);
-                    ret = new X509[numCerts];
+        /// <summary>
+        /// Call back used for sending TLS information
+        /// </summary>
+        /// <param name="ssl">pointer to ssl struct</param>
+        /// <param name="buf">buffer containing information to send</param>
+        /// <param name="sz">size of buffer to send</param>
+        /// <param name="ctx">optional information</param>
+        /// <returns>amount of information sent</returns>
+        private static int wolfSSLCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+        {
+            if (sz <= 0)
+            {
+                log(ERROR_LOG, "wolfssl send error, size less than 0");
+                return wolfssl.CBIO_ERR_GENERAL;
+            }
 
-                    for (i = 0; i < numCerts; i++) {
-                        IntPtr current = wolfSSL_sk_X509_pop(sk);
-                        if (current != IntPtr.Zero)
-                        {
-                            ret[i] = new X509(current, true);
-                        }
+            try
+            {
+                System.Runtime.InteropServices.GCHandle gch;
+                gch = GCHandle.FromIntPtr(ctx);
+
+                Socket con = (System.Net.Sockets.Socket)gch.Target;
+                Byte[] msg = new Byte[sz];
+                Marshal.Copy(buf, msg, 0, sz);
+                if (con.Send(msg, 0, msg.Length, SocketFlags.None) == 0 && sz != 0)
+                {
+                    /* no data sent and msg size is larger then 0, check for lost connection */
+                    if (con.Poll((con.SendTimeout > 0) ? con.SendTimeout : WC_WAIT, SelectMode.SelectWrite))
+                    {
+                        log(ERROR_LOG, "socket connection issue, suspect connection termination");
+                        return wolfssl.CBIO_ERR_CONN_CLOSE;
                     }
-                    wolfSSL_sk_X509_free(sk);
-                }
-                return ret;
-                
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
-                return ret;
-            }
+                }
+                return sz;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "socket connection issue " + e.ToString());
+                return wolfssl.CBIO_ERR_CONN_CLOSE;
+            }
         }
 
 
-        /// <summary>
-        /// Get the current WOLFSSL_X509_STORE_CTX error value
-        /// </summary>
-        /// <param name="x509Ctx">pointer to store to get error from</param>
-        public static int X509_STORE_CTX_get_error(IntPtr x509Ctx)
-        {
-            try
-            {
-                if (x509Ctx == IntPtr.Zero)
-                {
-                    log(ERROR_LOG, "pointer passed in was not set");
-                    return -1;
-                }
-                return wolfSSL_X509_STORE_CTX_get_error(x509Ctx);
-            }
-            catch (Exception e)
-            {
-                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
-                return -1;
-            }
+        /// <summary>
+        /// Call back used for sending DTLS information
+        /// </summary>
+        /// <param name="ssl">pointer to ssl struct</param>
+        /// <param name="buf">buffer containing information to send</param>
+        /// <param name="sz">size of buffer to send</param>
+        /// <param name="ctx">optional information</param>
+        /// <returns>amount of information sent</returns>
+        private static int wolfSSL_dtlsCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+        {
+            if (sz <= 0)
+            {
+                log(ERROR_LOG, "wolfssl dtls send error, size less than 0");
+                return wolfssl.CBIO_ERR_GENERAL;
+            }
+
+            try
+            {
+                System.Runtime.InteropServices.GCHandle gch;
+                gch = GCHandle.FromIntPtr(ctx);
+
+                DTLS_con con = (DTLS_con)gch.Target;
+
+                Byte[] msg = new Byte[sz];
+                Marshal.Copy(buf, msg, 0, sz);
+                con.udp.Send(msg, msg.Length, con.ep);
+                return msg.Length;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "socket connection issue " + e.ToString());
+                return wolfssl.CBIO_ERR_CONN_CLOSE;
+            }
         }
 
+
         /// <summary>
-        /// Print low level C library debug messages to stdout when compiled with macro DEBUG_WOLFSSL
+        /// Call back to allow receiving DTLS information
         /// </summary>
-        public static void Debugging_ON()
+        /// <param name="ssl">structure of ssl passed in</param>
+        /// <param name="buf">buffer to contain received msg</param>
+        /// <param name="sz">size of buffer</param>
+        /// <param name="ctx">optional information passed in</param>
+        /// <returns>size of message received</returns>
+        private static int wolfSSL_dtlsCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
         {
-            wolfSSL_Debugging_ON();
+            if (sz <= 0)
+            {
+                log(ERROR_LOG, "wolfssl dtls receive error, size less than 0");
+                return wolfssl.CBIO_ERR_GENERAL;
+            }
+
+            try
+            {
+                System.Runtime.InteropServices.GCHandle gch;
+                gch = GCHandle.FromIntPtr(ctx);
+                DTLS_con con = (DTLS_con)gch.Target;
+
+                Byte[] msg = con.udp.Receive(ref con.ep);
+                if (msg.Length > sz)
+                {
+                    log(ERROR_LOG, "wolfssl DTLS packet received was larger than buffer");
+                    return wolfssl.CBIO_ERR_GENERAL;
+                }
+
+                Marshal.Copy(msg, 0, buf, msg.Length);
+                return msg.Length;
+            }
+            catch (Exception e)
+            {
+                /* issue with receive or size of buffer */
+                log(ERROR_LOG, "socket read issue " + e.ToString());
+                return wolfssl.CBIO_ERR_CONN_CLOSE;
+            }
         }
 
+
         /// <summary>
-        /// Turn off low level C debug messages
+        /// Create a new ssl structure
         /// </summary>
-        public static void Debugging_OFF()
+        /// <param name="ctx">structure to create ssl structure from</param>
+        /// <returns>pointer to ssl structure</returns>
+        public static IntPtr new_ssl(IntPtr ctx)
         {
-            wolfSSL_Debugging_OFF();
-        }
-
-        /// <summary>
-        /// Set the function to use for logging
-        /// </summary>
-        /// <param name="input">Function that conforms as to loggingCb</param>
-        /// <returns>1 on success</returns>
-        public static int SetLogging(loggingCb input)
-        {
-            internal_log = input;
-            return SUCCESS;
-        }
-
-
-        /// <summary>
-        /// Log a message to set logging function
-        /// </summary>
-        /// <param name="lvl">Level of log message</param>
-        /// <param name="msg">Message to log</param>
-        public static void log(int lvl, string msg)
-        {
-            /* if log is not set then print nothing */
-            if (internal_log == null)
-                return;
-            StringBuilder ptr = new StringBuilder(msg);
-            internal_log(lvl, ptr);
-        }
-    }
-}
+            if (ctx == IntPtr.Zero)
+                return IntPtr.Zero;
+
+            try
+            {
+                ssl_handle io;
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "new_ssl ctx unwrap error");
+                    return IntPtr.Zero;
+                }
+
+                io = new ssl_handle();
+                io.set_ssl(wolfSSL_new(local_ctx));
+
+                /* check if null */
+                if (io.get_ssl() == IntPtr.Zero)
+                {
+                    return IntPtr.Zero;
+                }
+
+                /* keep memory pinned to be able to reference by address */
+                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Used for a server to accept a connection
+        /// </summary>
+        /// <param name="ssl">structure containing info for connection</param>
+        /// <returns>1 on success</returns>
+        public static int accept(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "accept ssl unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_accept(sslCtx);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "accept error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Used for a client to connect
+        /// </summary>
+        /// <param name="ssl">structure containing connection info</param>
+        /// <returns>1 on success</returns>
+        public static int connect(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "connect ssl unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_connect(sslCtx);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "connect error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Read message from secure connection
+        /// </summary>
+        /// <param name="ssl">structure containing info about connection</param>
+        /// <param name="buf">object to hold incoming message (Unicode format)</param>
+        /// <param name="sz">size of available memory in buf</param>
+        /// <returns>amount of data read on success</returns>
+        public static int read(IntPtr ssl, StringBuilder buf, int sz)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                IntPtr data;
+                int ret;
+                byte[] msg;
+
+                buf.Clear(); /* Clear incomming buffer */
+
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "read ssl unwrap error");
+                    return FAILURE;
+                }
+                data = Marshal.AllocHGlobal(sz);
+
+                ret = wolfSSL_read(sslCtx, data, sz);
+
+                if (ret >= 0)
+                {
+                    /* Get data that was sent across and store it using a literal read of
+                     * the conversion from bytes to character. Takes care of if
+                     * a null terminator is part of the message read.
+                     */
+                    msg = new byte[ret];
+                    Marshal.Copy(data, msg, 0, ret);
+                    for (int i = 0; i < ret; i++)
+                    {
+                        buf.Append(@Convert.ToChar(msg[i]));
+                    }
+                }
+                Marshal.FreeHGlobal(data);
+
+                return ret;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl read error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Read message from secure connection using a byte array
+        /// </summary>
+        /// <param name="ssl">structure containing info about connection</param>
+        /// <param name="buf">object to hold incoming message (raw bytes)</param>
+        /// <param name="sz">size of available memory in buf</param>
+        /// <returns>amount of data read on success</returns>
+        public static int read(IntPtr ssl, byte[] buf, int sz)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                IntPtr data;
+                int ret;
+
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "read ssl unwrap error");
+                    return FAILURE;
+                }
+                data = Marshal.AllocHGlobal(sz);
+
+                ret = wolfSSL_read(sslCtx, data, sz);
+
+                if (ret >= 0)
+                {
+                    Marshal.Copy(data, buf, 0, ret);
+                }
+                Marshal.FreeHGlobal(data);
+
+                return ret;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl read error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+
+        /// <summary>
+        /// Write message to secure connection
+        /// </summary>
+        /// <param name="ssl">structure containing connection info</param>
+        /// <param name="buf">message to send</param>
+        /// <param name="sz">size of the message</param>
+        /// <returns>amount sent on success</returns>
+        public static int write(IntPtr ssl, StringBuilder buf, int sz)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                IntPtr data;
+                int ret;
+
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "write ssl unwrap error");
+                    return FAILURE;
+                }
+
+                data = Marshal.AllocHGlobal(sz);
+                Marshal.Copy(System.Text.Encoding.Default.GetBytes(buf.ToString()), 0,
+                       data, System.Text.Encoding.Default.GetByteCount(buf.ToString()));
+                ret = wolfSSL_write(sslCtx, data, sz);
+                Marshal.FreeHGlobal(data);
+                return ret;
+
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl write error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Write message to secure connection
+        /// </summary>
+        /// <param name="ssl">structure containing connection info</param>
+        /// <param name="buf">message to send</param>
+        /// <param name="sz">size of the message</param>
+        /// <returns>amount sent on success</returns>
+        public static int write(IntPtr ssl, byte[] buf, int sz)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                IntPtr data;
+                int ret;
+
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "write ssl unwrap error");
+                    return FAILURE;
+                }
+                data = Marshal.AllocHGlobal(sz);
+                Marshal.Copy(buf, 0, data, sz);
+                ret = wolfSSL_write(sslCtx, data, sz);
+                Marshal.FreeHGlobal(data);
+                return ret;
+
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl write error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Free information stored in ssl struct
+        /// </summary>
+        /// <param name="ssl">pointer to ssl struct to free</param>
+        public static void free(IntPtr ssl)
+        {
+            try
+            {
+                IntPtr sslCtx;
+                GCHandle gch = GCHandle.FromIntPtr(ssl);
+                ssl_handle handles = (ssl_handle)gch.Target;
+
+                sslCtx = handles.get_ssl();
+                wolfSSL_free(sslCtx);
+                handles.free();
+                gch.Free();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl free error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Shutdown a connection
+        /// </summary>
+        /// <param name="ssl">pointer to ssl struct to close connection of</param>
+        /// <returns>1 on success</returns>
+        public static int shutdown(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return FAILURE;
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "shutdown ssl unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_shutdown(sslCtx);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl shutdwon error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Optional, can be used to set a custom receive function
+        /// </summary>
+        /// <param name="ctx">structure to set receive function in</param>
+        /// <param name="func">function to use when reading socket</param>
+        public static void SetIORecv(IntPtr ctx, CallbackIORecv_delegate func)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+
+                /* check if already stored handle needs freed */
+                gch = handles.get_receive();
+                if (!Object.Equals(gch, default(GCHandle)))
+                {
+                    gch.Free();
+                }
+
+                /* keep new function alive */
+                handles.set_receive(GCHandle.Alloc(func));
+
+                wolfSSL_CTX_SetIORecv(handles.get_ctx(), func);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl setIORecv error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Optional, can be used to set a custom send function
+        /// </summary>
+        /// <param name="ctx">structure to set function in</param>
+        /// <param name="func">function to use when sending data</param>
+        public static void SetIOSend(IntPtr ctx, CallbackIOSend_delegate func)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+
+                /* check if already stored handle needs freed */
+                gch = handles.get_send();
+                if (!Object.Equals(gch, default(GCHandle)))
+                {
+                    gch.Free();
+                }
+
+                /* keep new function alive */
+                handles.set_send(GCHandle.Alloc(func));
+
+                wolfSSL_CTX_SetIOSend(handles.get_ctx(), func);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl setIOSend error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Create a new CTX structure
+        /// </summary>
+        /// <param name="method">method to use such as TLSv1.2</param>
+        /// <returns>pointer to CTX structure</returns>
+        public static IntPtr CTX_new(IntPtr method)
+        {
+            try
+            {
+                IntPtr ctx = wolfSSL_CTX_new(method);
+                if (ctx == IntPtr.Zero)
+                    return ctx;
+
+                ctx_handle io = new ctx_handle();
+                io.set_ctx(ctx);
+
+                CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSLCbIORecv);
+                io.set_receive(GCHandle.Alloc(recv));
+                wolfSSL_CTX_SetIORecv(ctx, recv);
+
+                CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSLCbIOSend);
+                io.set_send(GCHandle.Alloc(send));
+                wolfSSL_CTX_SetIOSend(ctx, send);
+
+                /* keep memory pinned */
+                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "ctx_new error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Create a new CTX structure for a DTLS connection
+        /// </summary>
+        /// <param name="method">Method to use in connection ie DTLSv1.2</param>
+        /// <returns></returns>
+        public static IntPtr CTX_dtls_new(IntPtr method)
+        {
+            try
+            {
+                IntPtr ctx = wolfSSL_CTX_new(method);
+                if (ctx == IntPtr.Zero)
+                    return ctx;
+
+                ctx_handle io = new ctx_handle();
+                io.set_ctx(ctx);
+
+                CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSL_dtlsCbIORecv);
+                io.set_receive(GCHandle.Alloc(recv));
+                wolfSSL_CTX_SetIORecv(ctx, recv);
+
+                CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSL_dtlsCbIOSend);
+                io.set_send(GCHandle.Alloc(send));
+                wolfSSL_CTX_SetIOSend(ctx, send);
+
+                /* keep memory pinned */
+                return GCHandle.ToIntPtr(GCHandle.Alloc(io, GCHandleType.Pinned));
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "ctx_dtls_new error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Free information used in CTX structure
+        /// </summary>
+        /// <param name="ctx">structure to free</param>
+        public static void CTX_free(IntPtr ctx)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+                wolfSSL_CTX_free(handles.get_ctx());
+                handles.free();
+                gch.Free();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx free error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Set identity hint to use
+        /// </summary>
+        /// <param name="ctx">pointer to structure of ctx to set hint in</param>
+        /// <param name="hint">hint to use</param>
+        /// <returns>1 on success</returns>
+        public static int CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder hint)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX use psk identity hint unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_use_psk_identity_hint(local_ctx, hint);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl psk identity hint error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Set the function to use for PSK connections
+        /// </summary>
+        /// <param name="ctx">pointer to CTX that the function is set in</param>
+        /// <param name="psk_cb">PSK function to use</param>
+        public static void CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+
+                handles.set_psk(GCHandle.Alloc(psk_cb));
+                wolfSSL_CTX_set_psk_server_callback(handles.get_ctx(), psk_cb);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl psk server callback error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Set the function to use for PSK connections
+        /// </summary>
+        /// <param name="ctx">pointer to CTX that the function is set in</param>
+        /// <param name="psk_cb">PSK function to use</param>
+        public static void CTX_set_psk_client_callback(IntPtr ctx, psk_client_delegate psk_cb)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ctx);
+                ctx_handle handles = (ctx_handle)gch.Target;
+
+                handles.set_psk(GCHandle.Alloc(psk_cb));
+                wolfSSL_CTX_set_psk_client_callback(handles.get_ctx(), psk_cb);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl psk client callback error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Set the function to use for PSK connections on a single TLS/DTLS connection
+        /// </summary>
+        /// <param name="ctx">pointer to SSL that the function is set in</param>
+        /// <param name="psk_cb">PSK function to use</param>
+        public static void set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb)
+        {
+            try
+            {
+                GCHandle gch = GCHandle.FromIntPtr(ssl);
+                ssl_handle handles = (ssl_handle)gch.Target;
+
+                handles.set_psk(GCHandle.Alloc(psk_cb));
+                wolfSSL_set_psk_server_callback(handles.get_ssl(), psk_cb);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl psk server callback error " + e.ToString());
+            }
+        }
+
+
+        /// <summary>
+        /// Set Socket for TLS connection
+        /// </summary>
+        /// <param name="ssl">structure to set Socket in</param>
+        /// <param name="fd">Socket to use</param>
+        /// <returns>1 on success</returns>
+        public static int set_fd(IntPtr ssl, Socket fd)
+        {
+            /* sanity check on inputs */
+            if (ssl == IntPtr.Zero)
+            {
+                return FAILURE;
+            }
+
+            try
+            {
+                if (!fd.Equals(null))
+                {
+                    GCHandle gch = GCHandle.FromIntPtr(ssl);
+                    ssl_handle handles = (ssl_handle)gch.Target;
+                    IntPtr sslCtx = handles.get_ssl();
+                    IntPtr ptr;
+                    GCHandle fd_pin = GCHandle.Alloc(fd);
+
+                    if (sslCtx == IntPtr.Zero)
+                    {
+                        log(ERROR_LOG, "wolfssl error setting up fd!!");
+                        return FAILURE;
+                    }
+
+                    handles.set_fd(fd_pin);
+                    ptr = GCHandle.ToIntPtr(fd_pin);
+                    wolfSSL_SetIOWriteCtx(sslCtx, ptr); //pass along the socket for writing to
+                    wolfSSL_SetIOReadCtx(sslCtx, ptr); //pass along the socket for reading from
+
+                    return SUCCESS;
+                }
+
+                return FAILURE;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "Error setting up fd!! " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Get socket of a TLS connection
+        /// </summary>
+        /// <param name="ssl">structure to get socket from</param>
+        /// <returns>Socket object used for connection</returns>
+        public static Socket get_fd(IntPtr ssl)
+        {
+            try
+            {
+                IntPtr ptr;
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl get_fd error");
+                    return null;
+                }
+
+                ptr = wolfSSL_GetIOReadCtx(sslCtx);
+                if (ptr != IntPtr.Zero)
+                {
+                    GCHandle gch = GCHandle.FromIntPtr(ptr);
+                    return (System.Net.Sockets.Socket)gch.Target;
+                }
+                return null;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get_fd error " + e.ToString());
+                return null;
+            }
+        }
+
+
+
+        /// <summary>
+        /// Set information needed to send and receive a DTLS connection
+        /// </summary>
+        /// <param name="ssl">structure to set information in</param>
+        /// <param name="udp">UDP object to send and receive</param>
+        /// <param name="ep">End point of connection</param>
+        /// <returns>1 on success</returns>
+        public static int set_dtls_fd(IntPtr ssl, UdpClient udp, IPEndPoint ep)
+        {
+            /* sanity check on inputs */
+            if (ssl == IntPtr.Zero)
+            {
+                return FAILURE;
+            }
+
+            try
+            {
+                if (!udp.Equals(null) && !ep.Equals(null))
+                {
+                    IntPtr ptr;
+                    DTLS_con con;
+                    GCHandle gch = GCHandle.FromIntPtr(ssl);
+                    ssl_handle handles = (ssl_handle)gch.Target;
+                    GCHandle fd_pin;
+
+                    con = new DTLS_con();
+                    con.udp = udp;
+                    con.ep = ep;
+                    fd_pin = GCHandle.Alloc(con);
+                    handles.set_fd(fd_pin);
+                    ptr = GCHandle.ToIntPtr(fd_pin);
+                    wolfSSL_SetIOWriteCtx(handles.get_ssl(), ptr); //pass along the socket for writing to
+                    wolfSSL_SetIOReadCtx(handles.get_ssl(), ptr); //pass along the socket for reading from
+
+                    return SUCCESS;
+                }
+                return FAILURE;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "Error setting up fd!! " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Get the pointer to DTLS_con class used for connection
+        /// </summary>
+        /// <param name="ssl">structure to get connection from</param>
+        /// <returns>DTLS_con object</returns>
+        public static DTLS_con get_dtls_fd(IntPtr ssl)
+        {
+            try
+            {
+                IntPtr ptr;
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl get_dtls_fd error");
+                    return null;
+                }
+
+                ptr = wolfSSL_GetIOReadCtx(sslCtx);
+                if (ptr != IntPtr.Zero)
+                {
+                    GCHandle gch = GCHandle.FromIntPtr(ptr);
+                    return (DTLS_con)gch.Target;
+                }
+                return null;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get_dtls_fd error " + e.ToString());
+                return null;
+            }
+        }
+
+
+        /// <summary>
+        /// Get available cipher suites
+        /// </summary>
+        /// <param name="list">list to fill with cipher suite names</param>
+        /// <param name="sz">size of list available to fill</param>
+        /// <returns>1 on success</returns>
+        public static int get_ciphers(StringBuilder list, int sz)
+        {
+            try
+            {
+                return wolfSSL_get_ciphers(list, sz);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get_ciphers error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Initialize wolfSSL library
+        /// </summary>
+        /// <returns>1 on success</returns>
+        public static int Init()
+        {
+            try
+            {
+                return wolfSSL_Init();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl init error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Clean up wolfSSL library memory
+        /// </summary>
+        /// <returns>1 on success</returns>
+        public static int Cleanup()
+        {
+            try
+            {
+                return wolfSSL_Cleanup();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl cleanup error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Set up TLS version 1.2 method
+        /// </summary>
+        /// <returns>pointer to TLSv1.2 method</returns>
+        public static IntPtr useTLSv1_2_server()
+        {
+            try
+            {
+                return wolfTLSv1_2_server_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Set up TLS version 1.3 method
+        /// </summary>
+        /// <returns>pointer to TLSv1.3 method</returns>
+        public static IntPtr useTLSv1_3_server()
+        {
+            try
+            {
+                return wolfTLSv1_3_server_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Use any TLS version
+        /// </summary>
+        /// <returns>pointer to method</returns>
+        public static IntPtr usev23_server()
+        {
+            try
+            {
+                return wolfSSLv23_server_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Set up TLS version 1.2 method
+        /// </summary>
+        /// <returns>pointer to TLSv1.2 method</returns>
+        public static IntPtr useTLSv1_2_client()
+        {
+            try
+            {
+                return wolfTLSv1_2_client_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Set up TLS version 1.3 method
+        /// </summary>
+        /// <returns>pointer to TLSv1.3 method</returns>
+        public static IntPtr useTLSv1_3_client()
+        {
+            try
+            {
+                return wolfTLSv1_3_client_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Use any TLS version
+        /// </summary>
+        /// <returns>pointer to method</returns>
+        public static IntPtr usev23_client()
+        {
+            try
+            {
+                return wolfSSLv23_client_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Set up DTLS version 1.2
+        /// </summary>
+        /// <returns>pointer to DTLSv1.2 method</returns>
+        public static IntPtr useDTLSv1_2_server()
+        {
+            try
+            {
+                return wolfDTLSv1_2_server_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Set up DTLS version 1.2
+        /// </summary>
+        /// <returns>pointer to DTLSv1.2 method</returns>
+        public static IntPtr useDTLSv1_2_client()
+        {
+            try
+            {
+                return wolfDTLSv1_2_client_method();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl error " + e.ToString());
+                return IntPtr.Zero;
+            }
+        }
+
+
+        /// <summary>
+        /// Gets the current cipher suite being used in connection
+        /// </summary>
+        /// <param name="ssl">SSL struct to get cipher suite from</param>
+        /// <returns>string containing current cipher suite</returns>
+        public static string get_current_cipher(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return null;
+            try
+            {
+                IntPtr ssl_cipher;
+                IntPtr ssl_cipher_ptr;
+                string ssl_cipher_str;
+
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl get_current_cipher error");
+                    return null;
+                }
+
+                ssl_cipher = wolfSSL_get_current_cipher(sslCtx);
+                ssl_cipher_ptr = wolfSSL_CIPHER_get_name(ssl_cipher);
+                ssl_cipher_str = Marshal.PtrToStringAnsi(ssl_cipher_ptr);
+
+                return ssl_cipher_str;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get current cipher error " + e.ToString());
+                return null;
+            }
+        }
+
+
+        /// <summary>
+        /// Set available cipher suites for all ssl structs created from ctx
+        /// </summary>
+        /// <param name="ctx">CTX structure to set</param>
+        /// <param name="list">List full of ciphers suites</param>
+        /// <returns>1 on success</returns>
+        public static int CTX_set_cipher_list(IntPtr ctx, StringBuilder list)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX set cipher list error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_set_cipher_list(local_ctx, list);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx set cipher list error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Set available cipher suite in local connection
+        /// </summary>
+        /// <param name="ssl">Structure to set cipher suite in</param>
+        /// <param name="list">List of cipher suites</param>
+        /// <returns>1 on success</returns>
+        public static int set_cipher_list(IntPtr ssl, StringBuilder list)
+        {
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl set_cipher_list error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_set_cipher_list(sslCtx, list);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl set cipher error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Gets the version of the connection made ie TLSv1.2
+        /// </summary>
+        /// <param name="ssl">SSL struct to get version of</param>
+        /// <returns>string containing version</returns>
+        public static string get_version(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return null;
+
+            try
+            {
+                IntPtr version_ptr;
+                string version;
+
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl get_version error");
+                    return null;
+                }
+
+                version_ptr = wolfSSL_get_version(sslCtx);
+                version = Marshal.PtrToStringAnsi(version_ptr);
+
+                return version;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get version error " + e.ToString());
+                return null;
+            }
+        }
+
+
+        /// <summary>
+        /// Get a string containing error value and reason
+        /// </summary>
+        /// <param name="ssl">SSL struct that had error</param>
+        /// <returns>String containing error value and reason</returns>
+        public static string get_error(IntPtr ssl)
+        {
+            if (ssl == IntPtr.Zero)
+                return null;
+
+            try
+            {
+                int err;
+                StringBuilder err_name;
+                StringBuilder ret;
+
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "wolfssl get_error error");
+                    return null;
+                }
+
+                /* wolfSSL max error length is 80 */
+                ret = new StringBuilder(' ', 100);
+                err = wolfSSL_get_error(sslCtx, 0);
+                err_name = new StringBuilder(new String(' ', 80));
+                wolfSSL_ERR_error_string((uint)err, err_name);
+                ret.Append("Error " + err + " " + err_name.ToString());
+
+                return ret.ToString();
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl get error, error " + e.ToString());
+                return null;
+            }
+        }
+
+
+        /// <summary>
+        /// Used to load in the certificate file
+        /// </summary>
+        /// <param name="ctx">CTX structure for TLS/SSL connections</param>
+        /// <param name="fileCert">Name of the file to load including absolute path</param>
+        /// <param name="type">Type of file ie PEM or DER</param>
+        /// <returns>1 on success</returns>
+        public static int CTX_use_certificate_file(IntPtr ctx, string fileCert, int type)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX use certificate file error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_use_certificate_file(local_ctx, fileCert, type);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx use cert file error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Used to load in the peer trusted root file
+        /// </summary>
+        /// <param name="ctx">CTX structure for TLS/SSL connections</param>
+        /// <param name="fileCert">Name of the file to load including absolute path</param>
+        /// <param name="type">path to multiple certificates (try to load all in path) </param>
+        /// <returns>1 on success</returns>
+        public static int CTX_load_verify_locations(IntPtr ctx, string fileCert, string path)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX load verify locations certificate file error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_load_verify_locations(local_ctx, fileCert, path);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx load verify locations file error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+        /// <summary>
+        /// Used to load in the private key from a file
+        /// </summary>
+        /// <param name="ctx">CTX structure for TLS/SSL connections </param>
+        /// <param name="fileKey">Name of the file, includeing absolute directory</param>
+        /// <param name="type">Type of file ie PEM or DER</param>
+        /// <returns>1 on success</returns>
+        public static int CTX_use_PrivateKey_file(IntPtr ctx, string fileKey, int type)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX use PrivateKey file error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_use_PrivateKey_file(local_ctx, fileKey, type);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx use key file error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Set temporary DH parameters
+        /// </summary>
+        /// <param name="ssl">Structure to set in</param>
+        /// <param name="dhparam">file name</param>
+        /// <param name="file_type">type of file ie PEM</param>
+        /// <returns>1 on success</returns>
+        public static int SetTmpDH_file(IntPtr ssl, StringBuilder dhparam, int file_type)
+        {
+            try
+            {
+                IntPtr sslCtx = unwrap_ssl(ssl);
+                if (sslCtx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "SetTmpDH_file ssl unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_SetTmpDH_file(sslCtx, dhparam, file_type);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "SetTmpDH_file error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+        /// <summary>
+        /// Set temporary DH parameters
+        /// </summary>
+        /// <param name="ctx">Structure to set in</param>
+        /// <param name="dhparam">file name</param>
+        /// <param name="file_type">type of file ie PEM</param>
+        /// <returns>1 on success</returns>
+        public static int CTX_SetTmpDH_file(IntPtr ctx, StringBuilder dhparam, int file_type)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX_SetTmpDH_file ctx unwrap error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_SetTmpDH_file(local_ctx, dhparam, file_type);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "CTX_SetTmpDH_file error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Used to set the minimum size of DH key
+        /// </summary>
+        /// <param name="ctx">Structure to store key size</param>
+        /// <param name="minDhKey">Min key size </param>
+        /// <returns>1 on success</returns>
+        public static int CTX_SetMinDhKey_Sz(IntPtr ctx, short minDhKey)
+        {
+            try
+            {
+                IntPtr local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX SetMinDhKey_Sz error");
+                    return FAILURE;
+                }
+
+                return wolfSSL_CTX_SetMinDhKey_Sz(local_ctx, minDhKey);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx set min dh key error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+        /// <summary>
+        /// Set the certificate verification mode and optional callback function
+        /// </summary>
+        /// <param name="ctx">pointer to CTX that the function is set in</param>
+        /// <param name="mode">See SSL_VERIFY options</param>
+        /// <param name="vc">Optional verify callback function to use</param>
+        public static int CTX_set_verify(IntPtr ctx, int mode, CallbackVerify_delegate vc)
+        {
+            try
+            {
+                GCHandle   gch;
+                ctx_handle handles;
+                IntPtr     local_ctx = unwrap_ctx(ctx);
+                if (local_ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "CTX set_verify error");
+                    return FAILURE;
+                }
+
+                /* pin the verify callback to protect from garbage collection */
+                if (!vc.Equals(null)) {
+                    gch = GCHandle.FromIntPtr(ctx);
+                    handles = (ctx_handle)gch.Target;
+                    handles.set_vrf(GCHandle.Alloc(vc));
+                }
+
+                wolfSSL_CTX_set_verify(local_ctx, mode, vc);
+                return SUCCESS;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl ctx set verify error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+        /// <summary>
+        /// Set the certificate verification mode and optional callback function
+        /// </summary>
+        /// <param name="ctx">pointer to SSL object that the function is set in</param>
+        /// <param name="mode">See SSL_VERIFY options</param>
+        /// <param name="vc">Optional verify callback function to use</param>
+        public static int set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc)
+        {
+            try
+            {
+                GCHandle   gch;
+                ssl_handle handles;
+                IntPtr     local_ssl = unwrap_ssl(ssl);
+                if (local_ssl == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "set_verify error");
+                    return FAILURE;
+                }
+
+                /* pin the verify callback to protect from garbage collection */
+                if (!vc.Equals(null)) {
+                    gch = GCHandle.FromIntPtr(ssl);
+                    handles = (ssl_handle)gch.Target;
+                    handles.set_vrf(GCHandle.Alloc(vc));
+                }
+
+                wolfSSL_set_verify(local_ssl, mode, vc);
+                return SUCCESS;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl set verify error " + e.ToString());
+                return FAILURE;
+            }
+        }
+
+
+        /// <summary>
+        /// Set the certificate verification mode and optional callback function
+        /// </summary>
+        /// <param name="ctx">pointer to SSL object that the function is set in</param>
+        /// <param name="mode">See SSL_VERIFY options</param>
+        /// <param name="vc">Optional verify callback function to use</param>
+        public static X509 X509_STORE_CTX_get_current_cert(IntPtr x509Ctx)
+        {
+            X509 ret = null;
+            try
+            {
+                if (x509Ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "pointer passed in was not set");
+                    return ret;
+                }
+                IntPtr x509 = wolfSSL_X509_STORE_CTX_get_current_cert(x509Ctx);
+                if (x509 != IntPtr.Zero) {
+                    return new X509(x509, false);
+                }
+                return ret;
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
+                return ret;
+            }
+        }
+
+
+        /// <summary>
+        /// Gets all of the certificates from store
+        /// </summary>
+        /// <param name="x509Ctx">pointer to store to get certificates from</param>
+        public static X509[] X509_STORE_CTX_get_certs(IntPtr x509Ctx)
+        {
+            X509[] ret = null;
+            try
+            {
+                if (x509Ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "pointer passed in was not set");
+                    return ret;
+                }
+                IntPtr sk = wolfSSL_X509_STORE_GetCerts(x509Ctx);
+                if (sk != IntPtr.Zero) {
+                    int i;
+                    int numCerts = wolfSSL_sk_X509_num(sk);
+                    ret = new X509[numCerts];
+
+                    for (i = 0; i < numCerts; i++) {
+                        IntPtr current = wolfSSL_sk_X509_pop(sk);
+                        if (current != IntPtr.Zero)
+                        {
+                            ret[i] = new X509(current, true);
+                        }
+                    }
+                    wolfSSL_sk_X509_free(sk);
+                }
+                return ret;
+
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
+                return ret;
+            }
+        }
+
+
+        /// <summary>
+        /// Get the current WOLFSSL_X509_STORE_CTX error value
+        /// </summary>
+        /// <param name="x509Ctx">pointer to store to get error from</param>
+        public static int X509_STORE_CTX_get_error(IntPtr x509Ctx)
+        {
+            try
+            {
+                if (x509Ctx == IntPtr.Zero)
+                {
+                    log(ERROR_LOG, "pointer passed in was not set");
+                    return -1;
+                }
+                return wolfSSL_X509_STORE_CTX_get_error(x509Ctx);
+            }
+            catch (Exception e)
+            {
+                log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
+                return -1;
+            }
+        }
+
+        /// <summary>
+        /// Print low level C library debug messages to stdout when compiled with macro DEBUG_WOLFSSL
+        /// </summary>
+        public static void Debugging_ON()
+        {
+            wolfSSL_Debugging_ON();
+        }
+
+        /// <summary>
+        /// Turn off low level C debug messages
+        /// </summary>
+        public static void Debugging_OFF()
+        {
+            wolfSSL_Debugging_OFF();
+        }
+
+        /// <summary>
+        /// Set the function to use for logging
+        /// </summary>
+        /// <param name="input">Function that conforms as to loggingCb</param>
+        /// <returns>1 on success</returns>
+        public static int SetLogging(loggingCb input)
+        {
+            internal_log = input;
+            return SUCCESS;
+        }
+
+
+        /// <summary>
+        /// Log a message to set logging function
+        /// </summary>
+        /// <param name="lvl">Level of log message</param>
+        /// <param name="msg">Message to log</param>
+        public static void log(int lvl, string msg)
+        {
+            /* if log is not set then print nothing */
+            if (internal_log == null)
+                return;
+            StringBuilder ptr = new StringBuilder(msg);
+            internal_log(lvl, ptr);
+        }
+    }
+}

+ 1 - 1
wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj

@@ -72,7 +72,7 @@ xcopy "$(ProjectDir)..\..\..\certs\server-cert.pem" "$(TargetDir)" /Y /R
 xcopy "$(ProjectDir)..\..\..\certs\dh2048.pem" "$(TargetDir)" /Y /R
 xcopy "$(ProjectDir)..\..\..\certs\ca-cert.pem" "$(TargetDir)" /Y /R</PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>