Skip to content

Commit

Permalink
Allowed to set Wi-SUN certificates in DISCONNECTED state (#13071)
Browse files Browse the repository at this point in the history
Before certificates were able to set only once.
Now after disconnect those can be set Again

Also those can be set when stack is active
  • Loading branch information
Mika Tervonen authored Jun 10, 2020
1 parent c0ca645 commit 782141b
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions features/nanostack/mbed-mesh-api/source/wisun_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,44 +540,41 @@ int8_t wisun_tasklet_network_init(int8_t device_id)

int wisun_tasklet_set_own_certificate(uint8_t *cert, uint16_t cert_len, uint8_t *cert_key, uint16_t cert_key_len)
{
if (wisun_tasklet_data_ptr) {
// this API can be only used before first connect()
tr_err("Already connected");
return -2;
}

if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
// interface already active write certificates to stack.
arm_certificate_entry_s arm_cert_entry;
arm_cert_entry.cert = cert;
arm_cert_entry.cert_len = cert_len;
arm_cert_entry.key = cert_key;
arm_cert_entry.key_len = cert_key_len;
return arm_network_own_certificate_add(&arm_cert_entry);
}
// Stack is inactive store the certificates and activate when connect() called
return wisun_tasklet_store_certificate_data(cert, cert_len, cert_key, cert_key_len, false, false, false);
}

int wisun_tasklet_remove_own_certificates(void)
{
if (wisun_tasklet_data_ptr) {
// this API can be only used before first connect()
tr_err("Already connected");
return -2;
}

return wisun_tasklet_store_certificate_data(NULL, 0, NULL, 0, true, false, false);
}

int wisun_tasklet_remove_trusted_certificates(void)
{
if (wisun_tasklet_data_ptr) {
// this API can be only used before first connect()
tr_err("Already connected");
return -2;
}

return wisun_tasklet_store_certificate_data(NULL, 0, NULL, 0, false, true, false);
}

int wisun_tasklet_set_trusted_certificate(uint8_t *cert, uint16_t cert_len)
{
if (wisun_tasklet_data_ptr) {
// this API can be only used before first connect()
tr_err("Already connected");
return -2;
}
if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
// interface already active write certificates to stack.
arm_certificate_entry_s arm_cert_entry;
arm_cert_entry.cert = cert;
arm_cert_entry.cert_len = cert_len;
arm_cert_entry.key = NULL;
arm_cert_entry.key_len = 0;
return arm_network_trusted_certificate_add(&arm_cert_entry);
}
// Stack is inactive store the certificates and activate when connect() called
return wisun_tasklet_store_certificate_data(cert, cert_len, NULL, 0, false, false, true);
}

Expand Down

0 comments on commit 782141b

Please sign in to comment.