@@ -541,44 +541,41 @@ int8_t wisun_tasklet_network_init(int8_t device_id)
541
541
542
542
int wisun_tasklet_set_own_certificate (uint8_t * cert , uint16_t cert_len , uint8_t * cert_key , uint16_t cert_key_len )
543
543
{
544
- if (wisun_tasklet_data_ptr ) {
545
- // this API can be only used before first connect()
546
- tr_err ("Already connected" );
547
- return -2 ;
548
- }
549
-
544
+ if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr -> network_interface_id != INVALID_INTERFACE_ID ) {
545
+ // interface already active write certificates to stack.
546
+ arm_certificate_entry_s arm_cert_entry ;
547
+ arm_cert_entry .cert = cert ;
548
+ arm_cert_entry .cert_len = cert_len ;
549
+ arm_cert_entry .key = cert_key ;
550
+ arm_cert_entry .key_len = cert_key_len ;
551
+ return arm_network_own_certificate_add (& arm_cert_entry );
552
+ }
553
+ // Stack is inactive store the certificates and activate when connect() called
550
554
return wisun_tasklet_store_certificate_data (cert , cert_len , cert_key , cert_key_len , false, false, false);
551
555
}
552
556
553
557
int wisun_tasklet_remove_own_certificates (void )
554
558
{
555
- if (wisun_tasklet_data_ptr ) {
556
- // this API can be only used before first connect()
557
- tr_err ("Already connected" );
558
- return -2 ;
559
- }
560
-
561
559
return wisun_tasklet_store_certificate_data (NULL , 0 , NULL , 0 , true, false, false);
562
560
}
563
561
564
562
int wisun_tasklet_remove_trusted_certificates (void )
565
563
{
566
- if (wisun_tasklet_data_ptr ) {
567
- // this API can be only used before first connect()
568
- tr_err ("Already connected" );
569
- return -2 ;
570
- }
571
-
572
564
return wisun_tasklet_store_certificate_data (NULL , 0 , NULL , 0 , false, true, false);
573
565
}
574
566
575
567
int wisun_tasklet_set_trusted_certificate (uint8_t * cert , uint16_t cert_len )
576
568
{
577
- if (wisun_tasklet_data_ptr ) {
578
- // this API can be only used before first connect()
579
- tr_err ("Already connected" );
580
- return -2 ;
581
- }
569
+ if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr -> network_interface_id != INVALID_INTERFACE_ID ) {
570
+ // interface already active write certificates to stack.
571
+ arm_certificate_entry_s arm_cert_entry ;
572
+ arm_cert_entry .cert = cert ;
573
+ arm_cert_entry .cert_len = cert_len ;
574
+ arm_cert_entry .key = NULL ;
575
+ arm_cert_entry .key_len = 0 ;
576
+ return arm_network_trusted_certificate_add (& arm_cert_entry );
577
+ }
578
+ // Stack is inactive store the certificates and activate when connect() called
582
579
return wisun_tasklet_store_certificate_data (cert , cert_len , NULL , 0 , false, false, true);
583
580
}
584
581
0 commit comments