Skip to content

Commit

Permalink
Fix review findings #1
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrChaika committed Jun 27, 2023
1 parent db0b8ac commit 618d084
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/Download/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
13 changes: 8 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
)";

Expand Down
2 changes: 1 addition & 1 deletion utest/TestSelfUpdateScenarios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace {

ctx().messagingProtocol = std::make_shared<sua::MqttMessagingProtocolJSON>();
ctx().bundleChecker = std::make_shared<sua::BundleChecker>();
}
}

sua::SelfUpdateAgent sua;

Expand Down
6 changes: 3 additions & 3 deletions utest/sua-certificate.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[req]
default_bits = 2048
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_req
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

Expand Down

0 comments on commit 618d084

Please sign in to comment.