Skip to content

Commit 5fbbfee

Browse files
author
Mika Leppänen
committed
Added Wi-Sun certificate options to mesh api configuration json
Added possibility to configure Wi-Sun root certificate, own certificate and own certificate keys to mesh api.
1 parent 8e44a75 commit 5fbbfee

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

features/nanostack/mbed-mesh-api/mbed_lib.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@
153153
"wisun-uc-dwell-interval": {
154154
"help": "Unicast dwell interval. Range: 15-255 milliseconds",
155155
"value": 0
156+
},
157+
"certificate-header": {
158+
"help": "Certificate header",
159+
"value": null
160+
},
161+
"root-certificate": {
162+
"help": "Root certificate in PEM format (must be a null terminated c-string)",
163+
"value": null
164+
},
165+
"own-certificate": {
166+
"help": "Own certificate in PEM format (must be a null terminated c-string)",
167+
"value": null
168+
},
169+
"own-certificate-key": {
170+
"help": "Own certificate's key in PEM format (must be a null terminated c-string)",
171+
"value": null
156172
}
157173
},
158174
"target_overrides": {

features/nanostack/mbed-mesh-api/source/wisun_tasklet.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include "mac_api.h"
2929
#include "sw_mac.h"
3030
#include "ws_management_api.h" //ws_management_node_init
31+
#ifdef MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER
32+
#include MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER
33+
#endif
3134

3235
// For tracing we need to define flag, have include and define group
3336
//#define HAVE_DEBUG
@@ -210,6 +213,18 @@ static void wisun_tasklet_configure_and_connect_to_network(void)
210213
network_name,
211214
fhss_timer_ptr);
212215

216+
#if defined(MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER)
217+
arm_certificate_chain_entry_s chain_info;
218+
memset(&chain_info, 0, sizeof(arm_certificate_chain_entry_s));
219+
chain_info.cert_chain[0] = (const uint8_t *) MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE;
220+
chain_info.cert_len[0] = strlen((const char *) MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE) + 1;
221+
chain_info.cert_chain[1] = (const uint8_t *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE;
222+
chain_info.cert_len[1] = strlen((const char *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE) + 1;
223+
chain_info.key_chain[1] = (const uint8_t *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE_KEY;
224+
chain_info.chain_length = 2;
225+
arm_network_certificate_chain_set((const arm_certificate_chain_entry_s *) &chain_info);
226+
#endif
227+
213228
status = arm_nwk_interface_up(wisun_tasklet_data_ptr->network_interface_id);
214229
if (status >= 0) {
215230
wisun_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_STARTED;

0 commit comments

Comments
 (0)