@@ -448,23 +448,6 @@ void ziti_set_fully_authenticated(ziti_context ztx, const char *session_token) {
448448 ziti_posture_init (ztx , 20 );
449449}
450450
451- static void logout_cb (void * resp , const ziti_error * err , void * ctx ) {
452- ziti_context ztx = ctx ;
453-
454- ziti_set_unauthenticated (ztx , NULL );
455-
456- ziti_close_channels (ztx , ZITI_DISABLED );
457- ziti_ctrl_close (& ztx -> ctrl );
458-
459- model_map_clear (& ztx -> sessions , (_free_f ) free_ziti_session_ptr );
460- model_map_clear (& ztx -> services , (_free_f ) free_ziti_service_ptr );
461-
462- if (ztx -> closing ) {
463- ztx -> logout = true;
464- shutdown_and_free (ztx );
465- }
466- }
467-
468451void ziti_force_api_session_refresh (ziti_context ztx ) {
469452 ZTX_LOG (DEBUG , "forcing session refresh" );
470453 ztx -> auth_method -> force_refresh (ztx -> auth_method );
@@ -539,7 +522,6 @@ static void ziti_start_internal(ziti_context ztx, void *init_req) {
539522 if (!ztx -> enabled ) {
540523 ZTX_LOG (INFO , "enabling Ziti Context" );
541524 ztx -> enabled = true;
542- ztx -> logout = false;
543525
544526 int rc = load_tls (& ztx -> config , & ztx -> tlsCtx , & ztx -> id_creds );
545527 if (rc != 0 ) {
@@ -806,15 +788,12 @@ static void shutdown_and_free(ziti_context ztx) {
806788 return ;
807789 }
808790
809- if (!ztx -> logout ) {
810- ZTX_LOG (INFO , "waiting for logout" );
811- return ;
812- }
813-
814791 grim_reaper (ztx );
815792
816- ztx -> tlsCtx -> free_ctx (ztx -> tlsCtx );
817- ztx -> tlsCtx = NULL ;
793+ if (ztx -> tlsCtx ) {
794+ ztx -> tlsCtx -> free_ctx (ztx -> tlsCtx );
795+ ztx -> tlsCtx = NULL ;
796+ }
818797
819798 // N.B.: libuv processes close callbacks in reverse order
820799 // so we put the free on the first uv_close()
@@ -1609,12 +1588,14 @@ static void ca_bundle_cb(char *pkcs7, const ziti_error *err, void *ctx) {
16091588 ztx -> config .id .ca = new_pem ;
16101589
16111590 tls_context * new_tls = NULL ;
1591+ tls_context * old_tls = ztx -> tlsCtx ;
16121592 if (load_tls (& ztx -> config , & new_tls , & ztx -> id_creds ) == 0 ) {
16131593 ztx_config_update (ztx );
16141594 free (old_ca );
16151595 ztx -> tlsCtx = new_tls ;
16161596 tlsuv_http_set_ssl (ztx_get_controller (ztx )-> client , ztx -> tlsCtx );
16171597 new_pem = NULL ; // owned by ztx->config
1598+ old_tls -> free_ctx (old_tls );
16181599 } else {
16191600 ztx -> config .id .ca = old_ca ;
16201601 ZITI_LOG (ERROR , "failed to create TLS context with updated CA bundle" );
@@ -1760,7 +1741,7 @@ void ztx_prepare(uv_prepare_t *prep) {
17601741 ziti_channel_prepare (ch );
17611742 }
17621743
1763- if (!ztx -> enabled ) {
1744+ if (!ztx -> enabled || ztx -> closing ) {
17641745 uv_timer_stop (& ztx -> deadline_timer );
17651746 uv_prepare_stop (& ztx -> prepper );
17661747 }
0 commit comments