Skip to content

Commit a7dcd25

Browse files
committed
casync-http: Add cmdline option to trust ssl peers
This can be useful for testing, if ever we do HTTP2/SSL with a local, untrusted server. Signed-off-by: Arnaud Rebillout <[email protected]>
1 parent 7481f4b commit a7dcd25

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/casync-http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static volatile sig_atomic_t quit = false;
1515

1616
static bool arg_verbose = false;
1717
static curl_off_t arg_rate_limit_bps = 0;
18+
static bool arg_ssl_trust_peer = false;
1819

1920
typedef enum Protocol {
2021
PROTOCOL_HTTP,
@@ -162,6 +163,9 @@ static int make_curl_easy_handle(CURL **ret,
162163
if (private)
163164
CURL_SETOPT_EASY(h, CURLOPT_PRIVATE, private);
164165

166+
if (arg_ssl_trust_peer)
167+
CURL_SETOPT_EASY(h, CURLOPT_SSL_VERIFYPEER, false);
168+
165169
/* CURL_SETOPT_EASY(h, CURLOPT_VERBOSE, 1L); */
166170

167171
*ret = TAKE_PTR(h);
@@ -682,12 +686,14 @@ static int parse_argv(int argc, char *argv[]) {
682686

683687
enum {
684688
ARG_RATE_LIMIT_BPS = 0x100,
689+
ARG_SSL_TRUST_PEER,
685690
};
686691

687692
static const struct option options[] = {
688693
{ "help", no_argument, NULL, 'h' },
689694
{ "verbose", no_argument, NULL, 'v' },
690695
{ "rate-limit-bps", required_argument, NULL, ARG_RATE_LIMIT_BPS },
696+
{ "ssl-trust-peer", no_argument, NULL, ARG_SSL_TRUST_PEER },
691697
{}
692698
};
693699

@@ -728,6 +734,10 @@ static int parse_argv(int argc, char *argv[]) {
728734
arg_rate_limit_bps = strtoll(optarg, NULL, 10);
729735
break;
730736

737+
case ARG_SSL_TRUST_PEER:
738+
arg_ssl_trust_peer = true;
739+
break;
740+
731741
case '?':
732742
return -EINVAL;
733743

0 commit comments

Comments
 (0)