mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-26 22:20:59 +01:00
CLEANUP: acme: acme_will_expire() uses acme_schedule_date()
Date computation between acme_will_expire() and acme_schedule_date() are the same. Call acme_schedule_date() from acme_will_expire() and put the functions as static. The patch also move the functions in the right order.
This commit is contained in:
parent
f256b5fdf3
commit
c325e34e6d
51
src/acme.c
51
src/acme.c
@ -2346,41 +2346,12 @@ wait:
|
|||||||
MT_LIST_UNLOCK_FULL(&ctx->el, tmp);
|
MT_LIST_UNLOCK_FULL(&ctx->el, tmp);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Return 1 if the certificate must be regenerated
|
|
||||||
* Check if the notAfter date will append in (validity period / 12) or 7 days per default
|
|
||||||
*/
|
|
||||||
int acme_will_expire(struct ckch_store *store)
|
|
||||||
{
|
|
||||||
time_t diff = 0;
|
|
||||||
time_t notAfter = 0;
|
|
||||||
time_t notBefore = 0;
|
|
||||||
|
|
||||||
/* compute the validity period of the leaf certificate */
|
|
||||||
if (!store->data || !store->data->cert)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
notAfter = x509_get_notafter_time_t(store->data->cert);
|
|
||||||
notBefore = x509_get_notbefore_time_t(store->data->cert);
|
|
||||||
|
|
||||||
if ((notAfter >= 0 && notBefore >= 0)
|
|
||||||
&& (notAfter > notBefore)) {
|
|
||||||
diff = (notAfter - notBefore) / 12; /* validity period / 12 */
|
|
||||||
} else {
|
|
||||||
diff = 7 * 24 * 60 * 60; /* default to 7 days */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notAfter - diff <= date.tv_sec)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return when the next task is scheduled
|
* Return when the next task is scheduled
|
||||||
* Check if the notAfter date will happen in (validity period / 12) or 7 days per default
|
* Check if the notAfter date will happen in (validity period / 12) or 7 days per default
|
||||||
*/
|
*/
|
||||||
time_t acme_schedule_date(struct ckch_store *store)
|
static time_t acme_schedule_date(struct ckch_store *store)
|
||||||
{
|
{
|
||||||
time_t diff = 0;
|
time_t diff = 0;
|
||||||
time_t notAfter = 0;
|
time_t notAfter = 0;
|
||||||
@ -2406,6 +2377,26 @@ time_t acme_schedule_date(struct ckch_store *store)
|
|||||||
return (notAfter - diff);
|
return (notAfter - diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return 1 if the certificate must be regenerated
|
||||||
|
* Check if the notAfter date will append in (validity period / 12) or 7 days per default
|
||||||
|
*/
|
||||||
|
static int acme_will_expire(struct ckch_store *store)
|
||||||
|
{
|
||||||
|
time_t notAfter = 0;
|
||||||
|
|
||||||
|
/* compute the validity period of the leaf certificate */
|
||||||
|
if (!store->data || !store->data->cert)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
notAfter = acme_schedule_date(store);
|
||||||
|
|
||||||
|
if (notAfter <= date.tv_sec)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Does the scheduling of the ACME tasks
|
/* Does the scheduling of the ACME tasks
|
||||||
*/
|
*/
|
||||||
struct task *acme_scheduler(struct task *task, void *context, unsigned int state)
|
struct task *acme_scheduler(struct task *task, void *context, unsigned int state)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user