gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 04/31: testcurl/https: stopped CA file creation/removal


From: gnunet
Subject: [libmicrohttpd] 04/31: testcurl/https: stopped CA file creation/removal
Date: Mon, 10 Oct 2022 13:00:49 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 0be4e8c2a74bc70683aff1f8af9f225d2090d0c2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue Oct 4 14:18:00 2022 +0300

    testcurl/https: stopped CA file creation/removal
    
    Use CA cert file which is already in the filesystem
---
 src/testcurl/https/Makefile.am               |  6 +-----
 src/testcurl/https/test_https_multi_daemon.c | 12 -----------
 src/testcurl/https/test_https_sni.c          | 10 +++++-----
 src/testcurl/https/test_tls_authentication.c | 12 -----------
 src/testcurl/https/tls_test_common.c         | 30 ----------------------------
 src/testcurl/https/tls_test_common.h         |  5 +----
 6 files changed, 7 insertions(+), 68 deletions(-)

diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am
index fbd7f43f..6b9962b3 100644
--- a/src/testcurl/https/Makefile.am
+++ b/src/testcurl/https/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/src/include \
   -I$(top_srcdir)/src/microhttpd \
   -DMHD_CPU_COUNT=$(CPU_COUNT) \
+  -DSRCDIR=\"$(srcdir)\" \
   $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
 
 AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@
@@ -136,16 +137,11 @@ test_https_get_iovec_SOURCES = \
   tls_test_common.h \
   tls_test_common.c
 
-if HAVE_GNUTLS_SNI
 test_https_sni_SOURCES = \
   test_https_sni.c \
   tls_test_keys.h \
   tls_test_common.h \
   tls_test_common.c
-test_https_sni_CPPFLAGS = \
-  $(AM_CPPFLAGS) \
-  -DABS_SRCDIR=\"$(abs_srcdir)\"
-endif
 
 test_https_get_select_SOURCES = \
   test_https_get_select.c \
diff --git a/src/testcurl/https/test_https_multi_daemon.c 
b/src/testcurl/https/test_https_multi_daemon.c
index e8a9c13f..fdc8279b 100644
--- a/src/testcurl/https/test_https_multi_daemon.c
+++ b/src/testcurl/https/test_https_multi_daemon.c
@@ -131,7 +131,6 @@ int
 main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
-  FILE *cert;
   const char *aes256_sha = "AES256-SHA";
   (void) argc; (void) argv;       /* Unused. Silent compiler warning. */
 
@@ -149,12 +148,6 @@ main (int argc, char *const *argv)
     curl_global_cleanup ();
     return 77;
   }
-  if ((cert = setup_ca_cert ()) == NULL)
-  {
-    fprintf (stderr, MHD_E_TEST_FILE_CREAT);
-    curl_global_cleanup ();
-    return 99;
-  }
 
   if (curl_tls_is_nss ())
   {
@@ -167,10 +160,5 @@ main (int argc, char *const *argv)
   print_test_result (errorCount, "concurent_daemon_pair");
 
   curl_global_cleanup ();
-  fclose (cert);
-  if (0 != remove (ca_cert_file_name))
-    fprintf (stderr,
-             "Failed to remove `%s'\n",
-             ca_cert_file_name);
   return errorCount != 0 ? 1 : 0;
 }
diff --git a/src/testcurl/https/test_https_sni.c 
b/src/testcurl/https/test_https_sni.c
index 739feb1f..dda43e83 100644
--- a/src/testcurl/https/test_https_sni.c
+++ b/src/testcurl/https/test_https_sni.c
@@ -209,7 +209,7 @@ do_get (const char *url, uint16_t port)
   curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L);
   curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
   curl_easy_setopt (c, CURLOPT_FILE, &cbc);
-  curl_easy_setopt (c, CURLOPT_CAINFO, ABS_SRCDIR "/test-ca.crt");
+  curl_easy_setopt (c, CURLOPT_CAINFO, SRCDIR "/test-ca.crt");
 
   /* perform peer authentication */
   /* TODO merge into send_curl_req */
@@ -288,10 +288,10 @@ main (int argc, char *const *argv)
     return 77;
   }
 
-  load_keys ("mhdhost1", ABS_SRCDIR "/mhdhost1.crt",
-             ABS_SRCDIR "/mhdhost1.key");
-  load_keys ("mhdhost2", ABS_SRCDIR "/mhdhost2.crt",
-             ABS_SRCDIR "/mhdhost2.key");
+  load_keys ("mhdhost1", SRCDIR "/mhdhost1.crt",
+             SRCDIR "/mhdhost1.key");
+  load_keys ("mhdhost2", SRCDIR "/mhdhost2.crt",
+             SRCDIR "/mhdhost2.key");
   d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
                         | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
                         | MHD_USE_ERROR_LOG,
diff --git a/src/testcurl/https/test_tls_authentication.c 
b/src/testcurl/https/test_tls_authentication.c
index aa09460f..bedc3dd9 100644
--- a/src/testcurl/https/test_tls_authentication.c
+++ b/src/testcurl/https/test_tls_authentication.c
@@ -87,7 +87,6 @@ main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
   const char *aes256_sha = "AES256-SHA";
-  FILE *crt;
   (void) argc;
   (void) argv;       /* Unused. Silent compiler warning. */
 
@@ -106,13 +105,6 @@ main (int argc, char *const *argv)
     return 77;
   }
 
-  if (NULL == (crt = setup_ca_cert ()))
-  {
-    fprintf (stderr, MHD_E_TEST_FILE_CREAT);
-    curl_global_cleanup ();
-    return 99;
-  }
-  fclose (crt);
   if (curl_tls_is_nss ())
   {
     aes256_sha = "rsa_aes_256_sha";
@@ -124,9 +116,5 @@ main (int argc, char *const *argv)
   print_test_result (errorCount, argv[0]);
 
   curl_global_cleanup ();
-  if (0 != remove (ca_cert_file_name))
-    fprintf (stderr,
-             "Failed to remove `%s'\n",
-             ca_cert_file_name);
   return errorCount != 0 ? 1 : 0;
 }
diff --git a/src/testcurl/https/tls_test_common.c 
b/src/testcurl/https/tls_test_common.c
index cc04df9f..70606e67 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -27,36 +27,6 @@
 #include "tls_test_keys.h"
 
 
-FILE *
-setup_ca_cert (void)
-{
-  FILE *cert_fd;
-
-  if (NULL == (cert_fd = fopen (ca_cert_file_name, "wb+")))
-  {
-    fprintf (stderr, "Error: failed to open `%s': %s\n",
-             ca_cert_file_name, strerror (errno));
-    return NULL;
-  }
-  if (fwrite (ca_cert_pem, sizeof (char), strlen (ca_cert_pem) + 1, cert_fd)
-      != strlen (ca_cert_pem) + 1)
-  {
-    fprintf (stderr, "Error: failed to write `%s. %s'\n",
-             ca_cert_file_name, strerror (errno));
-    fclose (cert_fd);
-    return NULL;
-  }
-  if (fflush (cert_fd))
-  {
-    fprintf (stderr, "Error: failed to flush ca cert file stream. %s\n",
-             strerror (errno));
-    fclose (cert_fd);
-    return NULL;
-  }
-  return cert_fd;
-}
-
-
 /*
  * test HTTPS transfer
  */
diff --git a/src/testcurl/https/tls_test_common.h 
b/src/testcurl/https/tls_test_common.h
index f0cd7b8a..e6a61485 100644
--- a/src/testcurl/https/tls_test_common.h
+++ b/src/testcurl/https/tls_test_common.h
@@ -33,7 +33,7 @@
 #define CURL_VERBOS_LEVEL 0
 
 #define test_data "Hello World\n"
-#define ca_cert_file_name "tmp_ca_cert.pem"
+#define ca_cert_file_name SRCDIR "/test-ca.crt"
 
 #define EMPTY_PAGE \
   "<html><head><title>Empty page</title></head><body>Empty page</body></html>"
@@ -89,9 +89,6 @@ curl_tls_is_schannel (void);
 int
 curl_tls_is_sectransport (void);
 
-FILE *
-setup_ca_cert (void);
-
 /**
  * perform cURL request for file
  */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]