Skip to content

Commit 5f36041

Browse files
authored
Merge pull request #10598 from mikaleppanen/wisun_cert_conf
Add Wi-Sun certificate options to mesh api configuration json
2 parents e41d017 + 9e22354 commit 5f36041

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-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": "File name of the certificate header file (used on include directive)",
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
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+
#if !defined(MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE) || !defined(MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE) || \
33+
!defined(MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE_KEY)
34+
#error Invalid Wi-SUN certificate configuration
35+
#endif
36+
#include MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER
37+
#endif
3138

3239
// For tracing we need to define flag, have include and define group
3340
//#define HAVE_DEBUG
@@ -210,6 +217,18 @@ static void wisun_tasklet_configure_and_connect_to_network(void)
210217
network_name,
211218
fhss_timer_ptr);
212219

220+
#if defined(MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER)
221+
arm_certificate_chain_entry_s chain_info;
222+
memset(&chain_info, 0, sizeof(arm_certificate_chain_entry_s));
223+
chain_info.cert_chain[0] = (const uint8_t *) MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE;
224+
chain_info.cert_len[0] = strlen((const char *) MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE) + 1;
225+
chain_info.cert_chain[1] = (const uint8_t *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE;
226+
chain_info.cert_len[1] = strlen((const char *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE) + 1;
227+
chain_info.key_chain[1] = (const uint8_t *) MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE_KEY;
228+
chain_info.chain_length = 2;
229+
arm_network_certificate_chain_set((const arm_certificate_chain_entry_s *) &chain_info);
230+
#endif
231+
213232
status = arm_nwk_interface_up(wisun_tasklet_data_ptr->network_interface_id);
214233
if (status >= 0) {
215234
wisun_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_STARTED;

0 commit comments

Comments
 (0)