Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Add 'cainfo_path' option to 'storj_http_options' #365

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ int put_shard(storj_http_options_t *http_options,
curl_easy_setopt(curl, CURLOPT_PROXY, http_options->proxy_url);
}

if (http_options->cainfo_path) {
curl_easy_setopt(curl, CURLOPT_CAINFO, http_options->cainfo_path);
}

curl_easy_setopt(curl, CURLOPT_POST, 1);

struct curl_slist *header_list = NULL;
Expand Down Expand Up @@ -312,6 +316,10 @@ int fetch_shard(storj_http_options_t *http_options,
curl_easy_setopt(curl, CURLOPT_PROXY, http_options->proxy_url);
}

if (http_options->cainfo_path) {
curl_easy_setopt(curl, CURLOPT_CAINFO, http_options->cainfo_path);
}

char query_args[80];
snprintf(query_args, 80, "?token=%s", token);
int url_len = strlen(proto) + 3 + strlen(host) + 1 + 10
Expand Down Expand Up @@ -550,7 +558,12 @@ int fetch_json(storj_http_options_t *http_options,
curl_easy_setopt(curl, CURLOPT_PROXY, http_options->proxy_url);
}

// Set the timeoeut
// Set the path to the Certificate Authority (CA) bundle
if (http_options->cainfo_path) {
curl_easy_setopt(curl, CURLOPT_CAINFO, http_options->cainfo_path);
}

// Set the timeout
curl_easy_setopt(curl, CURLOPT_TIMEOUT, http_options->timeout);

// Setup the body handler
Expand Down
8 changes: 8 additions & 0 deletions src/storj.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ struct storj_env *storj_init_env(storj_bridge_options_t *options,
} else {
ho->proxy_url = NULL;
}
if (http_options->cainfo_path) {
ho->cainfo_path = strdup(http_options->cainfo_path);
} else {
ho->cainfo_path = NULL;
}
ho->low_speed_limit = http_options->low_speed_limit;
ho->low_speed_time = http_options->low_speed_time;
if (http_options->timeout == 0 ||
Expand Down Expand Up @@ -765,6 +770,9 @@ int storj_destroy_env(storj_env_t *env)
if (env->http_options->proxy_url) {
free((char *)env->http_options->proxy_url);
}
if (env->http_options->cainfo_path) {
free((char *)env->http_options->cainfo_path);
}
free(env->http_options);

// free the event loop
Expand Down
1 change: 1 addition & 0 deletions src/storj.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ typedef struct storj_encrypt_options {
typedef struct storj_http_options {
const char *user_agent;
const char *proxy_url;
const char *cainfo_path;
uint64_t low_speed_limit;
uint64_t low_speed_time;
uint64_t timeout;
Expand Down