diff --git a/nts_ntp_client.c b/nts_ntp_client.c index ed89edd..7e8e3fc 100644 --- a/nts_ntp_client.c +++ b/nts_ntp_client.c @@ -60,7 +60,6 @@ struct NNC_Instance_Record { NKC_Instance nke; SIV_Instance siv; - int load_attempt; int nke_attempts; double next_nke_attempt; double last_nke_success; @@ -94,7 +93,6 @@ reset_instance(NNC_Instance inst) SIV_DestroyInstance(inst->siv); inst->siv = NULL; - inst->load_attempt = 0; inst->nke_attempts = 0; inst->next_nke_attempt = 0.0; inst->last_nke_success = 0.0; @@ -129,6 +127,9 @@ NNC_CreateInstance(IPSockAddr *nts_address, const char *name, uint16_t ntp_port) reset_instance(inst); + /* Try to reload saved keys and cookies */ + load_cookies(inst); + return inst; } @@ -288,12 +289,6 @@ NNC_PrepareForAuth(NNC_Instance inst) UTI_GetRandomBytes(inst->uniq_id, sizeof (inst->uniq_id)); UTI_GetRandomBytes(inst->nonce, sizeof (inst->nonce)); - /* Try to reload saved keys and cookies (once for the NTS-KE address) */ - if (!inst->load_attempt) { - load_cookies(inst); - inst->load_attempt = 1; - } - /* Get new cookies if there are not any, or they are no longer usable */ if (!check_cookies(inst)) { if (!get_cookies(inst)) @@ -529,6 +524,8 @@ NNC_ChangeAddress(NNC_Instance inst, IPAddr *address) reset_instance(inst); DEBUG_LOG("NTS reset"); + + load_cookies(inst); } /* ================================================== */