Skip to content

Commit e73bf6f

Browse files
committed
aws_credentials: add https to endpoint if no scheme supplied
Signed-off-by: SagiROosto <[email protected]>
1 parent 8c17711 commit e73bf6f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/aws/flb_aws_credentials_iot.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,21 @@ struct flb_aws_provider *flb_iot_provider_create(struct flb_config *config,
290290
implementation->thing_name = flb_strdup(thing_name);
291291
implementation->role_alias = flb_strdup(role_alias);
292292

293+
/* Ensure credentials_endpoint has http or https scheme, default to https:// if missing */
294+
if (strncmp(credentials_endpoint, "http://", 7) != 0 &&
295+
strncmp(credentials_endpoint, "https://", 8) != 0) {
296+
flb_sds_t tmp = flb_sds_create_size(strlen(credentials_endpoint) + 8 + 1);
297+
if (!tmp) {
298+
flb_error("[aws_credentials] Failed to allocate memory for credentials_endpoint");
299+
goto error;
300+
}
301+
flb_sds_cat(tmp, "https://", 8);
302+
flb_sds_cat(tmp, credentials_endpoint, strlen(credentials_endpoint));
303+
flb_free(implementation->credentials_endpoint);
304+
implementation->credentials_endpoint = tmp;
305+
credentials_endpoint = implementation->credentials_endpoint;
306+
}
307+
293308
/* Parse the credentials endpoint URL */
294309
ret = flb_utils_url_split_sds(credentials_endpoint, &protocol, &host, &port_sds, &endpoint_path);
295310
if (ret < 0) {

0 commit comments

Comments
 (0)