Skip to content

Commit 54282bc

Browse files
author
Jenia Kogan
authored
Merge pull request #98 from PelionIoT/release-4.12.0
mbed-cloud-client 4.12.0
2 parents 08d12fb + 9e052d4 commit 54282bc

File tree

15 files changed

+2807
-13
lines changed

15 files changed

+2807
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Changelog for Pelion Device Management Client
22

3+
### Release 4.12.0 (01.03.2022)
4+
5+
- [Linux] Security improvement - the update encryption key is stored in the NVM and not in the header.
6+
- Enable connection to any LwM2M compliant bootstrap and device management services.
7+
- Introduce a new `LWM2M_COMPLIANT` flag that enables connection to any LwM2M compliant bootstrap and device management services. Disabled by default.
8+
- Introduce a new `DISABLE_SERVER_CERT_VERIFY` flag that disables the server certificate verification during the TLS handshake. Disabled by default.
9+
310
### Release 4.11.2 (01.12.2021)
411

512
Fixed a potential dead-lock situation in sn_nsdl.c CoAP tracing when tracing is enabled but trace-level is set below INFO. This fixes a regression introduced in 4.11.0 release.

factory-configurator-client/factory-configurator-client/factory-configurator-client/fcc_defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ extern const char g_fcc_class_id_name[];
178178

179179
extern const char g_fcc_vendor_id_name[];
180180

181+
#ifdef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
182+
extern const char g_fcc_mbed_internal_endpoint[];
183+
extern const char g_fcc_account_id[];
184+
#endif
181185

182186
#ifdef __cplusplus
183187
}

factory-configurator-client/factory-configurator-client/source/factory_configurator_client.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ const char g_fcc_update_authentication_certificate_name[] = "mbed.UpdateAuthCert
7474
const char g_fcc_class_id_name[] = "mbed.ClassId";
7575
const char g_fcc_vendor_id_name[] = "mbed.VendorId";
7676

77+
#ifdef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
78+
const char g_fcc_mbed_internal_endpoint[] = "mbed.InternalEndpoint";
79+
const char g_fcc_account_id[] = "mbed.AccountID";
80+
#endif
81+
7782
static bool g_is_fcc_initialized = false;
7883
bool g_is_session_finished = true;
7984

factory-configurator-client/factory-configurator-client/source/fcc_dev_flow.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,21 @@ extern const char MBED_CLOUD_DEV_HARDWARE_VERSION[];
5353
//device total memory
5454
extern const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB;
5555

56+
#ifdef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
57+
extern const char MBED_CLOUD_DEV_ACCOUNT_ID[];
58+
#endif
59+
5660

5761
fcc_status_e fcc_developer_flow(void)
5862
{
5963
kcm_status_e kcm_status = KCM_STATUS_SUCCESS;
6064
fcc_status_e fcc_status = FCC_STATUS_SUCCESS;
6165
const bool is_factory_item = true;
66+
#ifdef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
67+
static const uint32_t is_bootstrap_mode = 0;
68+
#else
6269
static const uint32_t is_bootstrap_mode = 1;
70+
#endif
6371
const fcc_deloveper_mode_item_params_s fcc_deloveper_mode_item_params_table[] = {
6472

6573
//param name //param kcm type //param data //param data_size
@@ -68,11 +76,25 @@ fcc_status_e fcc_developer_flow(void)
6876
#if !defined(MBED_CONF_MBED_CLOUD_CLIENT_SECURE_ELEMENT_SUPPORT) || (defined(MBED_CONF_MBED_CLOUD_CLIENT_SECURE_ELEMENT_SUPPORT) && defined(MBED_CONF_MBED_CLOUD_CLIENT_CLEAN_CREDENTIALS_SE))
6977
{ g_fcc_endpoint_parameter_name, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME, (uint32_t)strlen((char*)MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME) },
7078
//Bootstrap configuration
79+
#ifndef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
7180
{ g_fcc_bootstrap_device_certificate_name, KCM_CERTIFICATE_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE },
7281
{ g_fcc_bootstrap_device_private_key_name, KCM_PRIVATE_KEY_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE },
73-
#endif
82+
#else
83+
{ g_fcc_lwm2m_device_certificate_name, KCM_CERTIFICATE_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE },
84+
{ g_fcc_lwm2m_device_private_key_name, KCM_PRIVATE_KEY_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY, MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE },
85+
{ g_fcc_mbed_internal_endpoint, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME, (uint32_t)strlen((char*)MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME) },
86+
// The account id is not really needed, but the MCC requires it.
87+
{ g_fcc_account_id, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_ACCOUNT_ID, (uint32_t)strlen((char*)MBED_CLOUD_DEV_ACCOUNT_ID) },
88+
#endif //MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
89+
#endif //!defined(MBED_CONF_MBED_CLOUD_CLIENT_SECURE_ELEMENT_SUPPORT) || (defined(MBED_CONF_MBED_CLOUD_CLIENT_SECURE_ELEMENT_SUPPORT) && defined(MBED_CONF_MBED_CLOUD_CLIENT_CLEAN_CREDENTIALS_SE))
90+
91+
#ifndef MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
7492
{ g_fcc_bootstrap_server_ca_certificate_name, KCM_CERTIFICATE_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE, MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE },
7593
{ g_fcc_bootstrap_server_uri_name, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI, (uint32_t)strlen((char*)MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI) },
94+
#else
95+
{ g_fcc_lwm2m_server_ca_certificate_name, KCM_CERTIFICATE_ITEM, MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE, MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE },
96+
{ g_fcc_lwm2m_server_uri_name, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI, (uint32_t)strlen((char*)MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI) },
97+
#endif //MBED_CONF_MBED_CLIENT_DISABLE_BOOTSTRAP_FEATURE
7698
//device meta data
7799
{ g_fcc_manufacturer_parameter_name, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_MANUFACTURER, (uint32_t)strlen((char*)MBED_CLOUD_DEV_MANUFACTURER) },
78100
{ g_fcc_model_number_parameter_name, KCM_CONFIG_ITEM, (const uint8_t*)MBED_CLOUD_DEV_MODEL_NUMBER, (uint32_t)strlen((char*)MBED_CLOUD_DEV_MODEL_NUMBER) },
@@ -112,9 +134,10 @@ fcc_status_e fcc_developer_flow(void)
112134
SA_PV_ERR_RECOVERABLE_RETURN_IF((kcm_status != KCM_STATUS_SUCCESS), fcc_convert_kcm_to_fcc_status(kcm_status), "Store status: %d, Failed to store %s", kcm_status, mandatory_items_iter->item_name);
113135
}
114136

137+
#if defined (PAL_USE_SECURE_TIME) && (PAL_USE_SECURE_TIME == 1)
115138
fcc_status = fcc_trust_ca_cert_id_set();
116139
SA_PV_ERR_RECOVERABLE_RETURN_IF((fcc_status != FCC_STATUS_SUCCESS), fcc_status, "Failed to set ca certificate identifier");
117-
140+
#endif
118141
SA_PV_LOG_INFO_FUNC_EXIT_NO_ARGS();
119142

120143
return fcc_status;

factory-configurator-client/factory-configurator-client/source/fcc_verification.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static fcc_status_e fcc_check_uri_contents(bool use_bootstrap, uint8_t* uri_data
143143
SA_PV_ERR_RECOVERABLE_GOTO_IF(true, fcc_status = FCC_STATUS_URI_WRONG_FORMAT, exit, "Wrong uri prefix");
144144
}
145145

146+
#ifndef LWM2M_COMPLIANT // Account ID is a Pelion thing
146147
// Check if uri_string contains uri_aid (indicate the uri contains AccountId)
147148
if ((strstr(uri_string, URI_AID_PREFIX1) != NULL) || (strstr(uri_string, URI_AID_PREFIX2) != NULL)) {
148149
has_uri_aid = true;
@@ -154,6 +155,7 @@ static fcc_status_e fcc_check_uri_contents(bool use_bootstrap, uint8_t* uri_data
154155
} else {
155156
SA_PV_ERR_RECOVERABLE_GOTO_IF(has_uri_aid == false, fcc_status = FCC_STATUS_URI_WRONG_FORMAT, exit, "Wrong uri data");
156157
}
158+
#endif
157159

158160
exit:
159161
fcc_free(uri_string);
@@ -546,6 +548,7 @@ static fcc_status_e verify_root_ca_certificate(bool use_bootstrap)
546548
fcc_status = verify_existence_and_set_warning(secondary_ca_cert_name, secondary_ca_cert_name_len, KCM_CERTIFICATE_ITEM, false);
547549
SA_PV_ERR_RECOVERABLE_GOTO_IF((fcc_status != FCC_STATUS_SUCCESS), fcc_status = fcc_status, store_error_and_exit, "Failed in verify_existence_and_set_warning");
548550

551+
#if defined (PAL_USE_SECURE_TIME) && (PAL_USE_SECURE_TIME == 1)
549552
if (use_bootstrap == true) {
550553
fcc_status = fcc_get_certificate_attribute_by_name((const uint8_t*)root_ca_cert_name,
551554
root_ca_cert_name_len,
@@ -570,6 +573,7 @@ static fcc_status_e verify_root_ca_certificate(bool use_bootstrap)
570573
}
571574
fcc_status = FCC_STATUS_SUCCESS;
572575
}
576+
#endif //#if defined (PAL_USE_SECURE_TIME) && (PAL_USE_SECURE_TIME == 1)
573577

574578
//TBD : check of mbed crypto scheme IOTPREQ-1417
575579
store_error_and_exit:
@@ -709,11 +713,13 @@ static fcc_status_e verify_device_certificate_and_private_key(bool use_bootstrap
709713
fcc_status = compare_cn_with_endpoint(x509_cert_handle);
710714
SA_PV_ERR_RECOVERABLE_GOTO_IF((fcc_status != FCC_STATUS_SUCCESS), fcc_status = fcc_status, close_chain, "Failed to compare_cn_with_endpoint");
711715

716+
#ifndef LWM2M_COMPLIANT // Account ID is Pelion specific
712717
//In case LWM2M certificate check it's OU attribute with aid of server link
713718
if (strcmp((const char*)exist_item_name, g_fcc_lwm2m_device_certificate_name) == 0) {
714719
fcc_status = compare_ou_with_aid_server(x509_cert_handle);
715720
SA_PV_ERR_RECOVERABLE_GOTO_IF((fcc_status != FCC_STATUS_SUCCESS), fcc_status = fcc_status, close_chain, "Failed to compare_ou_with_aid_server");
716721
}
722+
#endif
717723

718724
//Check that device certificate not self-signed
719725
kcm_status = cs_is_self_signed_x509_cert(x509_cert_handle, &is_self_signed);

factory-configurator-client/fcc-bundle-handler/source/fcc_bundle_handler.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,10 @@ fcc_status_e fcc_bundle_handler(const uint8_t *encoded_blob, size_t encoded_blob
470470
// in SOTP, if in the future more error conditions will be attached to FCC_STATUS_CA_ERROR error code
471471
// then the logic here MUST be change.
472472
// Only if this is the last message - set the certificate ID
473+
#if defined (PAL_USE_SECURE_TIME) && (PAL_USE_SECURE_TIME == 1)
473474
fcc_status = fcc_trust_ca_cert_id_set();
474475
SA_PV_ERR_RECOVERABLE_GOTO_IF(((fcc_status != FCC_STATUS_SUCCESS) && (fcc_status != FCC_STATUS_CA_ERROR)), (fcc_status = fcc_status), exit_and_response, "CA store error %u", fcc_status);
475-
476+
#endif
476477
}
477478

478479
if (fcc_verify_status == true) {

fota/fota.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ static int prepare_and_program_header(void)
15891589

15901590
#if (MBED_CLOUD_CLIENT_FOTA_ENCRYPTION_SUPPORT == 1)
15911591
header_info.flags |= FOTA_HEADER_ENCRYPTED_FLAG;
1592-
#if (MBED_CLOUD_CLIENT_FOTA_KEY_ENCRYPTION == FOTA_USE_ENCRYPTED_ONE_TIME_FW_KEY)
1592+
#if (MBED_CLOUD_CLIENT_FOTA_KEY_ENCRYPTION == FOTA_USE_ENCRYPTED_ONE_TIME_FW_KEY) && !defined(TARGET_LIKE_LINUX)
15931593
// encrypt fw_key buffer using device key and store it in the header
15941594
uint8_t fw_key[FOTA_ENCRYPT_KEY_SIZE];
15951595
ret = fota_nvm_fw_encryption_key_get(fw_key);

fota/fota_candidate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ static int fota_candidate_extract_start(bool force_encrypt, const char *expected
269269
uint8_t zero_key[FOTA_ENCRYPT_KEY_SIZE] = {0};
270270
size_t volatile loop_check;
271271

272-
#if (MBED_CLOUD_CLIENT_FOTA_KEY_ENCRYPTION != FOTA_USE_ENCRYPTED_ONE_TIME_FW_KEY)
272+
#if (MBED_CLOUD_CLIENT_FOTA_KEY_ENCRYPTION != FOTA_USE_ENCRYPTED_ONE_TIME_FW_KEY) || \
273+
defined(TARGET_LIKE_LINUX)
273274
ret = fota_nvm_fw_encryption_key_get(fw_key);
274275
#else
275276
ret = fota_decrypt_fw_key(fw_key,

0 commit comments

Comments
 (0)