Skip to content

Commit 618d084

Browse files
Fix review findings #1
1 parent db0b8ac commit 618d084

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/Download/Downloader.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ namespace {
3636
bool cancelled = false;
3737
int progressNotificationLimiter = 0;
3838

39-
size_t write_data(void* ptr, size_t size, size_t nmemb, FILE* stream);
40-
sua::TechCode download(const char* url);
41-
4239
struct progress {
4340
char* unused;
4441
size_t size;
@@ -85,7 +82,7 @@ namespace {
8582
return written;
8683
}
8784

88-
sua::TechCode download(sua::Context & context, const char* url)
85+
sua::TechCode download(const char* certificateFileName, const char* url)
8986
{
9087
CURLcode gres = curl_global_init(CURL_GLOBAL_ALL);
9188
if(gres != 0) {
@@ -119,7 +116,7 @@ namespace {
119116

120117
curl_easy_setopt(easy_handle, CURLOPT_URL, url);
121118
curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &response_code);
122-
curl_easy_setopt(easy_handle, CURLOPT_CAINFO, context.certificateFileName.c_str());
119+
curl_easy_setopt(easy_handle, CURLOPT_CAINFO, certificateFileName);
123120
curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, 1);
124121
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_data);
125122
curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, fp);
@@ -162,7 +159,7 @@ namespace sua {
162159

163160
TechCode Downloader::start(const std::string & input)
164161
{
165-
return download(_context, input.c_str());
162+
return download(_context.certificateFileName.c_str(), input.c_str());
166163
}
167164

168165
} // namespace sua

src/main.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ SUA_SERVER sets and overrides MQTT server address to connect
4545
-h, --help display this help and exit
4646
-i, --installer set install method 'download' to download update bundles and let Rauc install them,
4747
'stream' to let Rauc install bundles directly from HTTP-server,
48-
or 'dummy' for neither download nor installation (default is 'download')
49-
-p, --path path where downloaded update bundles will be stored (default is '/data/selfupdates')
50-
-s, --server MQTT broker server to connect (default is 'tcp://mosquitto:1883')
51-
(has precedence over SUA_SERVER environment variable)
52-
-c, --ca path to certificate to verify connection with bundle server (default is '/etc/ssl/certs/selfupdateagent.crt')
48+
or 'dummy' for neither download nor installation
49+
(default is 'download')
50+
-p, --path path where downloaded update bundles will be stored
51+
(default is '/data/selfupdates')
52+
-s, --server MQTT broker server to connect, has precedence over SUA_SERVER environment variable
53+
(default is 'tcp://mosquitto:1883')
54+
-c, --ca path to certificate to verify connection with bundle server
55+
(default is '/etc/ssl/certs/selfupdateagent.crt')
5356
-v, --version display version (Git hash and build number) used to build SUA and exit
5457
)";
5558

utest/TestSelfUpdateScenarios.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ namespace {
191191

192192
ctx().messagingProtocol = std::make_shared<sua::MqttMessagingProtocolJSON>();
193193
ctx().bundleChecker = std::make_shared<sua::BundleChecker>();
194-
}
194+
}
195195

196196
sua::SelfUpdateAgent sua;
197197

utest/sua-certificate.config

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[req]
2-
default_bits = 2048
2+
default_bits = 2048
33
distinguished_name = req_distinguished_name
44
req_extensions = req_ext
55
x509_extensions = v3_req
66
prompt = no
77

88
[req_distinguished_name]
99
countryName = XX
10-
stateOrProvinceName = N/A
11-
localityName = N/A
10+
stateOrProvinceName = NA
11+
localityName = NA
1212
organizationName = Self-signed certificate
1313
commonName = 127.0.0.1
1414

0 commit comments

Comments
 (0)