Merge commit 'b6f26e1' from martinwguy/master

Add "cert" option for rpc server's self-signed SSL certificate
This commit is contained in:
pooler 2013-06-13 21:50:47 +02:00
commit 805ea94a4d
3 changed files with 10 additions and 0 deletions

View file

@ -135,6 +135,7 @@ static int num_processors;
static char *rpc_url; static char *rpc_url;
static char *rpc_userpass; static char *rpc_userpass;
static char *rpc_user, *rpc_pass; static char *rpc_user, *rpc_pass;
char *opt_cert;
char *opt_proxy; char *opt_proxy;
long opt_proxy_type; long opt_proxy_type;
struct thr_info *thr_info; struct thr_info *thr_info;
@ -172,6 +173,7 @@ Options:\n\
-O, --userpass=U:P username:password pair for mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\ -u, --user=USERNAME username for mining server\n\
-p, --pass=PASSWORD password for mining server\n\ -p, --pass=PASSWORD password for mining server\n\
--cert=FILE certificate for mining server using SSL\n\
-x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy\n\ -x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy\n\
-t, --threads=N number of miner threads (default: number of processors)\n\ -t, --threads=N number of miner threads (default: number of processors)\n\
-r, --retries=N number of times to retry if a network call fails\n\ -r, --retries=N number of times to retry if a network call fails\n\
@ -215,6 +217,7 @@ static struct option const options[] = {
{ "background", 0, NULL, 'B' }, { "background", 0, NULL, 'B' },
#endif #endif
{ "benchmark", 0, NULL, 1005 }, { "benchmark", 0, NULL, 1005 },
{ "cert", 1, NULL, 1001 },
{ "config", 1, NULL, 'c' }, { "config", 1, NULL, 'c' },
{ "debug", 0, NULL, 'D' }, { "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
@ -1149,6 +1152,10 @@ static void parse_arg (int key, char *arg)
free(opt_proxy); free(opt_proxy);
opt_proxy = strdup(arg); opt_proxy = strdup(arg);
break; break;
case 1001:
free(opt_cert);
opt_cert = strdup(arg);
break;
case 1005: case 1005:
opt_benchmark = true; opt_benchmark = true;
want_longpoll = false; want_longpoll = false;

View file

@ -167,6 +167,7 @@ extern bool want_longpoll;
extern bool have_longpoll; extern bool have_longpoll;
extern bool want_stratum; extern bool want_stratum;
extern bool have_stratum; extern bool have_stratum;
extern char *opt_cert;
extern char *opt_proxy; extern char *opt_proxy;
extern long opt_proxy_type; extern long opt_proxy_type;
extern bool use_syslog; extern bool use_syslog;

2
util.c
View file

@ -314,6 +314,8 @@ json_t *json_rpc_call(CURL *curl, const char *url,
if (opt_protocol) if (opt_protocol)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);
if (opt_cert)
curl_easy_setopt(curl, CURLOPT_CAINFO, opt_cert);
curl_easy_setopt(curl, CURLOPT_ENCODING, ""); curl_easy_setopt(curl, CURLOPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);