← Commit list

19d0f4acfa

Fredrik Blau
Fredrik Blau
2026-09-05
SUCCESS Duration: 428s

Subject

tool: (re)set SSL verification in --libcurl output

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/config2setopts.c+7 -5
@@ -409,11 +409,13 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl)
MY_SETOPT_STR(curl, CURLOPT_SSLKEYTYPE, config->key_type);
MY_SETOPT_STR(curl, CURLOPT_PROXY_SSLKEYTYPE, config->proxy_key_type);
- /* libcurl default is strict verifyhost -> 1L, verifypeer -> 1L */
- if(config->insecure_ok) {
- my_setopt_long(curl, CURLOPT_SSL_VERIFYPEER, 0);
- my_setopt_long(curl, CURLOPT_SSL_VERIFYHOST, 0);
- }
+ /* libcurl default is strict verifyhost -> 1L, verifypeer -> 1L. Set
+ these for every operation so --libcurl output does not retain
+ --insecure from a preceding --next operation. */
+ my_setopt_long_force(curl, CURLOPT_SSL_VERIFYPEER,
+ config->insecure_ok ? 0 : 1);
+ my_setopt_long_force(curl, CURLOPT_SSL_VERIFYHOST,
+ config->insecure_ok ? 0 : 1);
if(config->doh_insecure_ok) {
my_setopt_long(curl, CURLOPT_DOH_SSL_VERIFYPEER, 0);
src/tool_easysrc.c+9 -0
@@ -40,6 +40,7 @@ struct slist_wc *easysrc_toohard; /* Unconvertible setopt */
struct slist_wc *easysrc_clean; /* Clean up allocated data */
int easysrc_mime_count;
int easysrc_slist_count;
+static bool easysrc_performed;
static const char * const srchead[] = {
"/********* Sample code generated by the curl command line tool **********",
@@ -121,9 +122,15 @@ CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
CURLcode easysrc_init(void)
{
+ easysrc_performed = FALSE;
return easysrc_add(&easysrc_code, "curl = curl_easy_init();");
}
+bool easysrc_is_first(void)
+{
+ return !easysrc_performed;
+}
+
CURLcode easysrc_perform(void)
{
CURLcode result = CURLE_OK;
@@ -155,6 +162,8 @@ CURLcode easysrc_perform(void)
result = easysrc_add(&easysrc_code, "result = curl_easy_perform(curl);");
if(!result)
result = easysrc_add(&easysrc_code, "");
+ if(!result)
+ easysrc_performed = TRUE;
return result;
}
src/tool_easysrc.h+2 -0
@@ -44,6 +44,7 @@ extern CURLcode easysrc_addf(struct slist_wc **plist,
const char *fmt, ...) CURL_PRINTF(2, 3);
extern CURLcode easysrc_perform(void);
extern CURLcode easysrc_cleanup(void);
+extern bool easysrc_is_first(void);
void dumpeasysrc(void);
#else /* CURL_DISABLE_LIBCURL_OPTION is defined */
@@ -52,6 +53,7 @@ void dumpeasysrc(void);
#define easysrc_cleanup()
#define dumpeasysrc(x)
#define easysrc_perform() CURLE_OK
+#define easysrc_is_first() TRUE
#endif /* CURL_DISABLE_LIBCURL_OPTION */
src/tool_setopt.c+10 -0
@@ -631,6 +631,16 @@ CURLcode tool_setopt_long(CURL *curl, const char *name, CURLoption tag,
return result;
}
+CURLcode tool_setopt_long_force(CURL *curl, const char *name, CURLoption tag,
+ long lval)
+{
+ CURLcode result = curl_easy_setopt(curl, tag, lval);
+ if(global->libcurl && !result && (!easysrc_is_first() || lval == 0))
+ result = easysrc_addf(&easysrc_code, "curl_easy_setopt(curl, %s, %ldL);",
+ name, lval);
+ return result;
+}
+
/* options that set curl_off_t */
CURLcode tool_setopt_offt(CURL *curl, const char *name, CURLoption tag,
curl_off_t lval)
src/tool_setopt.h+4 -0
@@ -92,6 +92,8 @@ CURLcode tool_setopt_slist(CURL *curl, const char *name, CURLoption tag,
struct curl_slist *list);
CURLcode tool_setopt_long(CURL *curl, const char *name, CURLoption tag,
long lval);
+CURLcode tool_setopt_long_force(CURL *curl, const char *name, CURLoption tag,
+ long lval);
CURLcode tool_setopt_offt(CURL *curl, const char *name, CURLoption tag,
curl_off_t lval);
CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config,
@@ -100,6 +102,7 @@ CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config,
CURLcode tool_setopt_ptr(CURL *curl, const char *name, CURLoption tag, ...);
#define my_setopt_long(x, y, z) tool_setopt_long(x, #y, y, z)
+#define my_setopt_long_force(x, y, z) tool_setopt_long_force(x, #y, y, z)
#define my_setopt_offt(x, y, z) tool_setopt_offt(x, #y, y, z)
#define my_setopt_ptr(x, y, z) tool_setopt_ptr(x, #y, y, z)
#define my_setopt_str(x, y, z) tool_setopt_str(x, config, #y, y, z)
@@ -125,6 +128,7 @@ CURLcode tool_setopt_ptr(CURL *curl, const char *name, CURLoption tag, ...);
/* No --libcurl, so pass options directly to library */
#define my_setopt_long(x, y, z) curl_easy_setopt(x, y, (long)(z))
+#define my_setopt_long_force(x, y, z) curl_easy_setopt(x, y, (long)(z))
#define my_setopt_offt(x, y, z) curl_easy_setopt(x, y, (curl_off_t)(z))
#define my_setopt_ptr(x, y, z) curl_easy_setopt(x, y, z)
#define my_setopt_str(x, y, z) curl_easy_setopt(x, y, z)
tests/data/Makefile.am+2 -0
@@ -1700,6 +1700,7 @@ TESTCASES = \
test1676 \
test1677 \
test1678 \
+ test1679 \
test1680 \
test1681 \
test1682 \
@@ -2151,6 +2152,7 @@ EXTRA_DIST = \
data1463.txt \
data1465.c \
data1481.c \
+ data1679.c \
data1705-1.md \
data1705-2.md \
data1705-3.md \
tests/data/data1679.c+80 -0
@@ -0,0 +1,80 @@
+/********* Sample code generated by the curl command line tool **********
+ * All curl_easy_setopt() options are documented at:
+ * https://curl.se/libcurl/c/curl_easy_setopt.html
+ ************************************************************************/
+#include <curl/curl.h>
+
+int main(int argc, char *argv[])
+{
+ CURLcode result;
+ CURL *curl;
+
+ curl = curl_easy_init();
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 102400L);
+ curl_easy_setopt(curl, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/%VERSION");
+ curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+ curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1_2);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+
+ /* Here is a list of options the curl code used that cannot get generated
+ as source easily. You may choose to either not use them or implement
+ them yourself.
+
+ CURLOPT_DEBUGFUNCTION was set to a function pointer
+ CURLOPT_DEBUGDATA was set to an object pointer
+ CURLOPT_WRITEDATA was set to an object pointer
+ CURLOPT_WRITEFUNCTION was set to a function pointer
+ CURLOPT_READDATA was set to an object pointer
+ CURLOPT_READFUNCTION was set to a function pointer
+ CURLOPT_SEEKDATA was set to an object pointer
+ CURLOPT_SEEKFUNCTION was set to a function pointer
+ CURLOPT_HEADERFUNCTION was set to a function pointer
+ CURLOPT_HEADERDATA was set to an object pointer
+ CURLOPT_ERRORBUFFER was set to an object pointer
+ CURLOPT_STDERR was set to an object pointer
+
+ */
+
+ result = curl_easy_perform(curl);
+
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 102400L);
+ curl_easy_setopt(curl, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/%VERSION");
+ curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1L);
+ curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1_2);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+
+ /* Here is a list of options the curl code used that cannot get generated
+ as source easily. You may choose to either not use them or implement
+ them yourself.
+
+ CURLOPT_DEBUGFUNCTION was set to a function pointer
+ CURLOPT_DEBUGDATA was set to an object pointer
+ CURLOPT_WRITEDATA was set to an object pointer
+ CURLOPT_WRITEFUNCTION was set to a function pointer
+ CURLOPT_READDATA was set to an object pointer
+ CURLOPT_READFUNCTION was set to a function pointer
+ CURLOPT_SEEKDATA was set to an object pointer
+ CURLOPT_SEEKFUNCTION was set to a function pointer
+ CURLOPT_HEADERFUNCTION was set to a function pointer
+ CURLOPT_HEADERDATA was set to an object pointer
+ CURLOPT_ERRORBUFFER was set to an object pointer
+ CURLOPT_STDERR was set to an object pointer
+
+ */
+
+ result = curl_easy_perform(curl);
+
+ curl_easy_cleanup(curl);
+ curl = NULL;
+
+ return (int)result;
+}
+/**** End of sample code ****/
tests/data/test1679+59 -0
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+--libcurl
+--next
+--insecure
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 0
+Connection: close
+
+</data>
+</reply>
+
+<client>
+<features>
+http
+SSL
+--libcurl
+</features>
+<server>
+http
+</server>
+<name>
+--libcurl resets SSL verification after --next
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c --insecure --next http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol crlf="headers">
+GET /we/want/%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+GET /we/want/%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stripfile>
+# CURLOPT_INTERLEAVEDATA requires RTSP protocol
+$_ = '' if /CURLOPT_INTERLEAVEDATA/
+</stripfile>
+<file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
+%includetext %SRCDIR/data/data1679.c%
+</file>
+</verify>
+</testcase>