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