- Platform specific function to correctly set the path for the certificates;

- Updated all the examples with it;
This commit is contained in:
gasbytes
2024-06-05 13:28:30 +02:00
parent 6cb97a7262
commit 2ab709c89a
9 changed files with 130 additions and 52 deletions

View File

@@ -116,9 +116,14 @@ public class wolfSSL_TLS_ServerThreaded
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");
string fileCert = wolfssl.setPath("server-cert.pem");
string fileKey = wolfssl.setPath("server-key.pem");
StringBuilder dhparam = new StringBuilder(wolfssl.setPath("dh2048.pem"));
if (fileCert == "" || fileKey == "" || dhparam.Length == 0) {
Console.WriteLine("Platform not supported");
return;
}
/* example of function used for setting logging */
wolfssl.SetLogging(standard_log);
@@ -140,6 +145,12 @@ public class wolfSSL_TLS_ServerThreaded
return;
}
if (!File.Exists(dhparam.ToString())) {
Console.WriteLine("Could not find dh 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");