@@ -693,6 +693,21 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da
goto cleanup;
}
+ if ((channel_data->api_key_header) && (channel_data->api_key)) {
+ char *header;
+ if (ENOMEM_ASPRINTF == asprintf(&header, "%s: %s", channel_data->api_key_header, channel_data->api_key)) {
+ result = CHANNEL_EINIT;
+ goto cleanup;
+ }
+ if (((channel_curl->header = curl_slist_append(
+ channel_curl->header, header)) == NULL)) {
+ free(header);
+ result = CHANNEL_EINIT;
+ goto cleanup;
+ }
+ free(header);
+ }
+
if (channel_data->received_headers || channel_data->headers) {
if ((curl_easy_setopt(channel_curl->handle,
CURLOPT_HEADERFUNCTION,
@@ -59,6 +59,12 @@ int channel_settings(void *elem, void *data)
GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
if (strlen(tmp))
SETSTRING(chan->iface, tmp);
+ GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "api_key_header", tmp);
+ if (strlen(tmp))
+ SETSTRING(chan->api_key_header, tmp);
+ GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "api_key", tmp);
+ if (strlen(tmp))
+ SETSTRING(chan->api_key, tmp);
return 0;
}
@@ -220,6 +220,17 @@ The downloader is thought as dummy servant: it starts the connection, retrieves
and sends them back to the caller. The delta handler is then responsible to parse the answer, and to
retrieve the missing chunks from the multipart HTTP body.
+Configuration_
+..............
+
+The delta handler is configured in the runtime configuration file (swupdate.cfg). The configuration is done in the
+`delta` section. See also example/configuration/swupdate.cfg for details.
+
+api_key_ authentication can be setup by providing the api_key_header and api_key in the configuration file. The
+api_key_header is the header name that will be used to send the api_key. The api_key is the value that will be sent in
+the header.
+
+
Creation of ZCK Header and ZCK file for SWUpdate
------------------------------------------------
@@ -282,6 +282,10 @@ webserver :
# sslcert : string
# path of the file containing the certificate for SSL connection or pkcs11 URI
# (ex. "pkcs11:model=ATECC608B;token=0ABC;serial=0123456789abcdef;object=device;type=cert")
+# api_key_header : string
+# HTTP header name for the API key
+# api_key : string
+# API key for the delta update server
delta :
{
sslkey = "/etc/ssl/sslkey";
@@ -95,4 +95,6 @@ typedef struct {
size_t upload_filesize;
char *range; /* Range request for get_file in any */
void *user;
+ char *api_key_header;
+ char *api_key;
} channel_data_t;