From c89107af4d1b8c3c8c0510440335ccfc277c007c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 22 Sep 2015 14:49:42 +0200 Subject: [PATCH] make SSL certificate checks configurable --- server/include/ngsi.h | 2 ++ server/src/ngsi.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/server/include/ngsi.h b/server/include/ngsi.h index 58c13f23c..f8d08a060 100644 --- a/server/include/ngsi.h +++ b/server/include/ngsi.h @@ -35,7 +35,9 @@ struct node; struct ngsi { const char *endpoint; const char *token; + double timeout; + int ssl_verify; enum ngsi_structure { NGSI_FLAT, diff --git a/server/src/ngsi.c b/server/src/ngsi.c index 23047106c..08df54bfe 100644 --- a/server/src/ngsi.c +++ b/server/src/ngsi.c @@ -239,6 +239,9 @@ int ngsi_parse(config_setting_t *cfg, struct node *n) if (!config_setting_lookup_string(cfg, "endpoint", &i->endpoint)) cerror(cfg, "Missing NGSI endpoint for node '%s'", n->name); + if (!config_setting_lookup_bool(cfg, "ssl_verify", &i->ssl_verify)) + i->ssl_verify = 1; /* verify by default */ + if (!config_setting_lookup_float(cfg, "timeout", &i->timeout)) i->timeout = 1; /* default value */ @@ -293,6 +296,7 @@ int ngsi_open(struct node *n) snprintf(buf, sizeof(buf), "%s/v1/updateContext", i->endpoint); curl_easy_setopt(i->curl, CURLOPT_URL, buf); + curl_easy_setopt(i->curl, CURLOPT_SSL_VERIFYPEER, i->ssl_verify); curl_easy_setopt(i->curl, CURLOPT_TIMEOUT_MS, i->timeout * 1e3); curl_easy_setopt(i->curl, CURLOPT_HTTPHEADER, i->headers);