break;
}
charon->bus->ike_state_change(charon->bus, &this->public, state);
- if (state == IKE_ESTABLISHED)
- { /* purge auth items after hook invocation, as they contain certs
- * and other memory wasting elements */
- this->my_auth->purge(this->my_auth);
- this->other_auth->purge(this->other_auth);
- }
this->state = state;
}
status = this->task_manager->process_message(this->task_manager, message);
if (status != DESTROY_ME)
{
+ if (message->get_exchange_type(message) == IKE_AUTH &&
+ this->state == IKE_ESTABLISHED)
+ {
+ /* purge auth items if SA is up, as they contain certs
+ * and other memory wasting elements */
+ this->my_auth->purge(this->my_auth);
+ this->other_auth->purge(this->other_auth);
+ }
return status;
}
/* if IKE_SA gets closed for any reasons, reroute routed children */