mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13072 from mikter/ws_certificate_set_change_5.15
[mbed-os-5.15] Allowed to set Wi-SUN certificates in DISCONNECTED statepull/13125/head
commit
0515ed1f9f
|
@ -541,44 +541,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)
|
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) {
|
if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
|
||||||
// this API can be only used before first connect()
|
// interface already active write certificates to stack.
|
||||||
tr_err("Already connected");
|
arm_certificate_entry_s arm_cert_entry;
|
||||||
return -2;
|
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);
|
return wisun_tasklet_store_certificate_data(cert, cert_len, cert_key, cert_key_len, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wisun_tasklet_remove_own_certificates(void)
|
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);
|
return wisun_tasklet_store_certificate_data(NULL, 0, NULL, 0, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wisun_tasklet_remove_trusted_certificates(void)
|
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);
|
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)
|
int wisun_tasklet_set_trusted_certificate(uint8_t *cert, uint16_t cert_len)
|
||||||
{
|
{
|
||||||
if (wisun_tasklet_data_ptr) {
|
if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
|
||||||
// this API can be only used before first connect()
|
// interface already active write certificates to stack.
|
||||||
tr_err("Already connected");
|
arm_certificate_entry_s arm_cert_entry;
|
||||||
return -2;
|
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);
|
return wisun_tasklet_store_certificate_data(cert, cert_len, NULL, 0, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue