From 6cb97a7262c27450960a57e5efc6d89d49d9b1fc Mon Sep 17 00:00:00 2001 From: gasbytes Date: Tue, 4 Jun 2024 23:12:16 +0200 Subject: [PATCH] fixed windows build path problem --- .../wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs index e5b56e91d..c273f6331 100644 --- a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs +++ b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs @@ -80,6 +80,19 @@ public class wolfSSL_TLS_CSHarp return 0; } + public static string setPath(string file) { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return @"../../certs/" + file; + } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return @"../../../../certs/" + file; + } else + { + return ""; + } + } + public static void Main(string[] args) { IntPtr ctx; @@ -88,8 +101,13 @@ public class wolfSSL_TLS_CSHarp IntPtr arg_sni; /* These paths should be changed for use */ - string fileCert = @"../../certs/server-cert.pem"; - string fileKey = @"../../certs/server-key.pem"; + string fileCert = setPath("server-cert.pem"); + string fileKey = setPath("server-key.pem"); + if (fileCert == "" || fileKey == "") { + Console.WriteLine("Platform not supported."); + return; + } + StringBuilder dhparam = new StringBuilder("dh2048.pem"); StringBuilder buff = new StringBuilder(1024);