Skip to content

Commit 7688174

Browse files
committed
Option to pass CA_INFO through to curl
1 parent d310a37 commit 7688174

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/https_client.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ static void https_fetch_ctx_init(https_client_t *client,
320320
DLOG_REQ("Using curl proxy: %s", client->opt->curl_proxy);
321321
ASSERT_CURL_EASY_SETOPT(ctx, CURLOPT_PROXY, client->opt->curl_proxy);
322322
}
323+
if (client->opt->ca_info) {
324+
ASSERT_CURL_EASY_SETOPT(ctx, CURLOPT_CAINFO, client->opt->ca_info);
325+
}
323326
CURLMcode multi_code = curl_multi_add_handle(client->curlm, ctx->curl);
324327
if (multi_code != CURLM_OK) {
325328
FLOG_REQ("curl_multi_add_handle error %d: %s",

src/options.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void options_init(struct Options *opt) {
4141

4242
int options_parse_args(struct Options *opt, int argc, char **argv) {
4343
int c = 0;
44-
while ((c = getopt(argc, argv, "a:c:p:du:g:b:i:4r:e:t:l:vxqs:hV")) != -1) {
44+
while ((c = getopt(argc, argv, "a:c:p:du:g:b:i:4r:e:t:l:vxqs:C:hV")) != -1) {
4545
switch (c) {
4646
case 'a': // listen_addr
4747
opt->listen_addr = optarg;
@@ -97,6 +97,9 @@ int options_parse_args(struct Options *opt, int argc, char **argv) {
9797
case 's': // stats interval
9898
opt->stats_interval = atoi(optarg);
9999
break;
100+
case 'C': // CA info
101+
opt->ca_info = optarg;
102+
break;
100103
case '?':
101104
printf("Unknown option '-%c'\n", c);
102105
// fallthrough
@@ -206,6 +209,8 @@ void options_show_usage(int __attribute__((unused)) argc, char **argv) {
206209
printf(" -s statistic_interval Optional statistic printout interval.\n"\
207210
" (Default: %d, Disabled: 0, Min: 1, Max: 3600)\n",
208211
defaults.stats_interval);
212+
printf(" -C path Optional directory containing CA "
213+
"certificates.\n");
209214
printf(" -v Increase logging verbosity. (Default: error)\n");
210215
printf(" Levels: fatal, stats, error, warning, info, debug\n");
211216
printf(" Request issues are logged on warning level.\n");

src/options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct Options {
4848

4949
// Print statistic interval
5050
int stats_interval;
51+
52+
// Path to a file containing CA certificates
53+
const char *ca_info;
5154
};
5255
typedef struct Options options_t;
5356

0 commit comments

Comments
 (0)