Strengthen some SSL options, pave the way for future options and public key pinning.
This commit is contained in:
@@ -7,6 +7,7 @@ struct cosmo {
|
|||||||
char client_id[COSMO_UUID_SIZE];
|
char client_id[COSMO_UUID_SIZE];
|
||||||
char instance_id[COSMO_UUID_SIZE];
|
char instance_id[COSMO_UUID_SIZE];
|
||||||
cosmo_callbacks callbacks;
|
cosmo_callbacks callbacks;
|
||||||
|
cosmo_options options;
|
||||||
void *passthrough;
|
void *passthrough;
|
||||||
|
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ json_t *cosmo_get_last_message(cosmo *instance, json_t *subject) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_callbacks *callbacks, void *passthrough) {
|
cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_callbacks *callbacks, const cosmo_options *options, void *passthrough) {
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|
||||||
cosmo *instance = malloc(sizeof(cosmo));
|
cosmo *instance = malloc(sizeof(cosmo));
|
||||||
@@ -577,6 +577,11 @@ cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_cal
|
|||||||
instance->debug = getenv("COSMO_DEBUG");
|
instance->debug = getenv("COSMO_DEBUG");
|
||||||
|
|
||||||
memcpy(&instance->callbacks, callbacks, sizeof(instance->callbacks));
|
memcpy(&instance->callbacks, callbacks, sizeof(instance->callbacks));
|
||||||
|
if (options) {
|
||||||
|
memcpy(&instance->options, options, sizeof(instance->options));
|
||||||
|
} else {
|
||||||
|
memset(&instance->options, 0, sizeof(instance->options));
|
||||||
|
}
|
||||||
instance->passthrough = passthrough;
|
instance->passthrough = passthrough;
|
||||||
|
|
||||||
if (client_id) {
|
if (client_id) {
|
||||||
@@ -597,7 +602,8 @@ cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_cal
|
|||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_URL, api_url));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_URL, api_url));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_SSL_CIPHER_LIST, "ECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2));
|
||||||
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_SSL_CIPHER_LIST, "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_TIMEOUT_MS, CYCLE_MS));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_TIMEOUT_MS, CYCLE_MS));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_POST, 1L));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_POST, 1L));
|
||||||
assert(!curl_easy_setopt(instance->curl, CURLOPT_READFUNCTION, cosmo_read_callback));
|
assert(!curl_easy_setopt(instance->curl, CURLOPT_READFUNCTION, cosmo_read_callback));
|
||||||
|
|||||||
@@ -19,11 +19,14 @@ typedef struct {
|
|||||||
void (*message)(const json_t *, void *);
|
void (*message)(const json_t *, void *);
|
||||||
} cosmo_callbacks;
|
} cosmo_callbacks;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
} cosmo_options;
|
||||||
|
|
||||||
typedef struct cosmo cosmo;
|
typedef struct cosmo cosmo;
|
||||||
|
|
||||||
void cosmo_uuid(char *uuid);
|
void cosmo_uuid(char *uuid);
|
||||||
|
|
||||||
cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_callbacks *callbacks, void *passthrough);
|
cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_callbacks *callbacks, const cosmo_options *options, void *passthrough);
|
||||||
void cosmo_shutdown(cosmo *instance);
|
void cosmo_shutdown(cosmo *instance);
|
||||||
|
|
||||||
const char *cosmo_current_profile(cosmo *instance);
|
const char *cosmo_current_profile(cosmo *instance);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ cosmo *create_client(test_state *state) {
|
|||||||
.message = on_message,
|
.message = on_message,
|
||||||
};
|
};
|
||||||
|
|
||||||
cosmo *ret = cosmo_create("https://playground.cosmopolite.org/cosmopolite", NULL, &callbacks, state);
|
cosmo *ret = cosmo_create("https://playground.cosmopolite.org/cosmopolite", NULL, &callbacks, NULL, state);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user