[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 01/04: HTTPS tests: ensure that CURL options were applie
From: |
gnunet |
Subject: |
[libmicrohttpd] 01/04: HTTPS tests: ensure that CURL options were applied |
Date: |
Thu, 10 Jun 2021 20:26:08 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 77a30308be834ac3b18a4aadf88ccbd4446f5be4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Jun 10 15:27:12 2021 +0300
HTTPS tests: ensure that CURL options were applied
---
src/testcurl/https/tls_test_common.c | 117 +++++++++++++++++++++++------------
1 file changed, 78 insertions(+), 39 deletions(-)
diff --git a/src/testcurl/https/tls_test_common.c
b/src/testcurl/https/tls_test_common.c
index fc998317..7027e78f 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -70,6 +70,7 @@ test_daemon_get (void *cls,
CURL *c;
struct CBC cbc;
CURLcode errornum;
+ CURLcode e;
char url[255];
size_t len;
(void) cls; /* Unused. Silence compiler warning. */
@@ -92,29 +93,48 @@ test_daemon_get (void *cls,
#if DEBUG_HTTPS_TEST
curl_easy_setopt (c, CURLOPT_VERBOSE, 1L);
#endif
- curl_easy_setopt (c, CURLOPT_URL, url);
- curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
- curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L);
- curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L);
- curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer);
- curl_easy_setopt (c, CURLOPT_FILE, &cbc);
+ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_URL, url))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_HTTP_VERSION,
+ CURL_HTTP_VERSION_1_0))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION,
+ ©Buffer))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FILE, &cbc))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L))))
+ {
+ fprintf (stderr, "curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
/* TLS options */
- curl_easy_setopt (c, CURLOPT_SSLVERSION, proto_version);
- curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST, cipher_suite);
-
- /* perform peer authentication */
- /* TODO merge into send_curl_req */
- curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, ver_peer);
- if (ver_peer)
- curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name);
- curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L);
- curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
-
- /* NOTE: use of CONNECTTIMEOUT without also
- setting NOSIGNAL results in really weird
- crashes on my system! */
- curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSLVERSION,
+ proto_version))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST,
+ cipher_suite))) ||
+
+ /* perform peer authentication */
+ /* TODO merge into send_curl_req */
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER,
+ ver_peer))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L))))
+ {
+ fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
+ if (ver_peer &&
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name)))
+ {
+ fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
if (CURLE_OK != (errornum = curl_easy_perform (c)))
{
fprintf (stderr, "curl_easy_perform failed: `%s'\n",
@@ -250,35 +270,54 @@ send_curl_req (char *url,
{
CURL *c;
CURLcode errornum;
+ CURLcode e;
c = curl_easy_init ();
#if DEBUG_HTTPS_TEST
curl_easy_setopt (c, CURLOPT_VERBOSE, CURL_VERBOS_LEVEL);
#endif
- curl_easy_setopt (c, CURLOPT_URL, url);
- curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
- curl_easy_setopt (c, CURLOPT_TIMEOUT, 60L);
- curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 60L);
+ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_URL, url))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_HTTP_VERSION,
+ CURL_HTTP_VERSION_1_0))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_TIMEOUT, 60L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 60L))) ||
+
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L))))
+ {
+ fprintf (stderr, "curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
if (cbc != NULL)
{
- curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer);
- curl_easy_setopt (c, CURLOPT_FILE, cbc);
+ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION,
+ ©Buffer))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FILE, cbc))))
+ {
+ fprintf (stderr, "curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
}
/* TLS options */
- curl_easy_setopt (c, CURLOPT_SSLVERSION, proto_version);
- curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST, cipher_suite);
-
- /* currently skip any peer authentication */
- curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L);
- curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L);
-
- curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
+ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSLVERSION,
+ proto_version))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST,
+ cipher_suite))) ||
+ /* currently skip any peer authentication */
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L))) ||
+ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L))))
+ {
+ fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n",
+ curl_easy_strerror (e));
+ curl_easy_cleanup (c);
+ return e;
+ }
- /* NOTE: use of CONNECTTIMEOUT without also
- setting NOSIGNAL results in really weird
- crashes on my system! */
- curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
if (CURLE_OK != (errornum = curl_easy_perform (c)))
{
fprintf (stderr, "curl_easy_perform failed: `%s'\n",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.