Skip to content

Commit a0982ba

Browse files
author
Pierre Belanger
committed
MINOR: added '--client-certfile' program command-line argument
This option allows to specify a PEM file to use as client certificate when connecting to a mirror-url over https.
1 parent 2025ab2 commit a0982ba

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

NEWS

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2021-04-16
2+
3+
- added option "-C --client-certfile=FILE"
4+
5+
This option allows to specify a PEM file to use as client certificate
6+
when connecting to a mirror-url over https.
7+
8+
Ex. : spoa-mirror --client-certfile=/path/ssl/clientcert.pem \
9+
--mirror-url https://vip_sslclient_yourdomain.com/ ...

README

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Options are:
9292
-B, --libev-backend=TYPE Specify the libev backend type (default: AUTO).
9393
-b, --connection-backlog=VALUE Specify the connection backlog size (default: 10).
9494
-c, --capability=NAME Enable the support of the specified capability.
95+
-C, --client-certfile=FILE Specifies a PEM file to use as client certificate.
9596
-D, --daemonize Run this program as a daemon.
9697
-F, --pidfile=FILE Specifies a file to write the process-id to.
9798
-h, --help Show this text.

include/types/main.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/***
22
* Copyright 2018-2020 HAProxy Technologies
3+
* Copyright 2021 Verizon Media, Pierre Belanger
34
*
45
* This file is part of spoa-mirror.
56
*
@@ -74,6 +75,7 @@ struct config_data {
7475
const char *pidfile;
7576
int pidfile_fd;
7677
uint ev_backend;
78+
const char *client_certfile;
7779
#ifdef HAVE_LIBCURL
7880
char *mir_url;
7981
const char *mir_address;

src/curl.c

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/***
22
* Copyright 2018-2020 HAProxy Technologies
3+
* Copyright 2021 Verizon Media, Pierre Belanger
34
*
45
* This file is part of spoa-mirror.
56
*
@@ -979,6 +980,9 @@ int mir_curl_add(struct curl_data *curl, struct mirror *mir)
979980
CURL_ERR_EASY("Failed to set read timeout", rc);
980981
else if ((rc = mir_curl_add_keepalive(con, 1, CURL_KEEPIDLE_TIME, CURL_KEEPINTVL_TIME)) != CURLE_OK)
981982
/* Do nothing. */;
983+
else if ((rc = curl_easy_setopt(con->easy, CURLOPT_SSLCERT, cfg.client_certfile)) != CURLE_OK)
984+
CURL_ERR_EASY("Failed to set client_certfile", rc);
985+
982986
else if ((rc = mir_curl_add_post(con, mir)) == CURLE_OK) {
983987
CURL_DBG("Adding easy %p to multi %p (%s)", con->easy, curl->multi, mir->url);
984988

src/main.c

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/***
22
* Copyright 2018-2020 HAProxy Technologies
3+
* Copyright 2021 Verizon Media, Pierre Belanger
34
*
45
* This file is part of spoa-mirror.
56
*
@@ -64,6 +65,7 @@ static void usage(const char *program_name, bool_t flag_verbose)
6465
(void)printf(" -B, --libev-backend=TYPE Specify the libev backend type (default: AUTO).\n");
6566
(void)printf(" -b, --connection-backlog=VALUE Specify the connection backlog size (default: %d).\n", DEFAULT_CONNECTION_BACKLOG);
6667
(void)printf(" -c, --capability=NAME Enable the support of the specified capability.\n");
68+
(void)printf(" -C, --client-certfile=FILE Specifies a PEM file to use as client certificate.\n");
6769
(void)printf(" -D, --daemonize Run this program as a daemon.\n");
6870
#ifdef DEBUG
6971
(void)printf(" -d, --debug=LEVEL Enable and specify the debug mode level (default: %d).\n", DEFAULT_DEBUG_LEVEL);
@@ -348,6 +350,7 @@ int main(int argc, char **argv, char **envp __maybe_unused)
348350
{ "libev-backend", required_argument, NULL, 'B' },
349351
{ "connection-backlog", required_argument, NULL, 'b' },
350352
{ "capability", required_argument, NULL, 'c' },
353+
{ "client-certfile", required_argument, NULL, 'C' },
351354
{ "daemonize", no_argument, NULL, 'D' },
352355
{ "debug", required_argument, NULL, 'd' },
353356
{ "pidfile", required_argument, NULL, 'F' },
@@ -394,6 +397,8 @@ int main(int argc, char **argv, char **envp __maybe_unused)
394397
cfg.connection_backlog = atoi(optarg);
395398
else if (c == 'c')
396399
flag_error |= _OK(getopt_set_capability(optarg)) ? 0 : 1;
400+
else if (c == 'C')
401+
cfg.client_certfile = optarg;
397402
else if (c == 'D')
398403
cfg.opt_flags |= FLAG_OPT_DAEMONIZE;
399404
#ifdef DEBUG

0 commit comments

Comments
 (0)