diff --git a/src/Download/Downloader.cpp b/src/Download/Downloader.cpp index eaa08b8..2c93ca0 100644 --- a/src/Download/Downloader.cpp +++ b/src/Download/Downloader.cpp @@ -36,9 +36,6 @@ namespace { bool cancelled = false; int progressNotificationLimiter = 0; - size_t write_data(void* ptr, size_t size, size_t nmemb, FILE* stream); - sua::TechCode download(const char* url); - struct progress { char* unused; size_t size; @@ -85,7 +82,7 @@ namespace { return written; } - sua::TechCode download(sua::Context & context, const char* url) + sua::TechCode download(const char* certificateFileName, const char* url) { CURLcode gres = curl_global_init(CURL_GLOBAL_ALL); if(gres != 0) { @@ -119,7 +116,7 @@ namespace { curl_easy_setopt(easy_handle, CURLOPT_URL, url); curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &response_code); - curl_easy_setopt(easy_handle, CURLOPT_CAINFO, context.certificateFileName.c_str()); + curl_easy_setopt(easy_handle, CURLOPT_CAINFO, certificateFileName); curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, 1); curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, fp); @@ -162,7 +159,7 @@ namespace sua { TechCode Downloader::start(const std::string & input) { - return download(_context, input.c_str()); + return download(_context.certificateFileName.c_str(), input.c_str()); } } // namespace sua diff --git a/src/main.cpp b/src/main.cpp index 5b96936..82ec7f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,11 +45,14 @@ SUA_SERVER sets and overrides MQTT server address to connect -h, --help display this help and exit -i, --installer set install method 'download' to download update bundles and let Rauc install them, 'stream' to let Rauc install bundles directly from HTTP-server, - or 'dummy' for neither download nor installation (default is 'download') --p, --path path where downloaded update bundles will be stored (default is '/data/selfupdates') --s, --server MQTT broker server to connect (default is 'tcp://mosquitto:1883') - (has precedence over SUA_SERVER environment variable) --c, --ca path to certificate to verify connection with bundle server (default is '/etc/ssl/certs/selfupdateagent.crt') + or 'dummy' for neither download nor installation + (default is 'download') +-p, --path path where downloaded update bundles will be stored + (default is '/data/selfupdates') +-s, --server MQTT broker server to connect, has precedence over SUA_SERVER environment variable + (default is 'tcp://mosquitto:1883') +-c, --ca path to certificate to verify connection with bundle server + (default is '/etc/ssl/certs/selfupdateagent.crt') -v, --version display version (Git hash and build number) used to build SUA and exit )"; diff --git a/utest/TestSelfUpdateScenarios.cpp b/utest/TestSelfUpdateScenarios.cpp index 9d9a73d..7694a8f 100644 --- a/utest/TestSelfUpdateScenarios.cpp +++ b/utest/TestSelfUpdateScenarios.cpp @@ -191,7 +191,7 @@ namespace { ctx().messagingProtocol = std::make_shared(); ctx().bundleChecker = std::make_shared(); - } + } sua::SelfUpdateAgent sua; diff --git a/utest/sua-certificate.config b/utest/sua-certificate.config index 2b9ca26..a1f698f 100644 --- a/utest/sua-certificate.config +++ b/utest/sua-certificate.config @@ -1,5 +1,5 @@ [req] -default_bits = 2048 +default_bits = 2048 distinguished_name = req_distinguished_name req_extensions = req_ext x509_extensions = v3_req @@ -7,8 +7,8 @@ prompt = no [req_distinguished_name] countryName = XX -stateOrProvinceName = N/A -localityName = N/A +stateOrProvinceName = NA +localityName = NA organizationName = Self-signed certificate commonName = 127.0.0.1