Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cert rotation not happening when expiryTime and cron scheduled run are equal #212

Open
junaid-ali opened this issue Nov 29, 2021 · 0 comments · May be fixed by #213
Open

cert rotation not happening when expiryTime and cron scheduled run are equal #212

junaid-ali opened this issue Nov 29, 2021 · 0 comments · May be fixed by #213

Comments

@junaid-ali
Copy link
Contributor

junaid-ali commented Nov 29, 2021

Before() function , that we are using here, compares if a time has happened before the time provided as the argument and returns false if both times are equal.

nextRun := cronSchedule.Next(time.Now())
if expiryTime.Before(nextRun) {
return true, "Certificate about to expire, rotating certificate"
}

We need to trigger cert rotation before/equals/close to actual cert expiration. For that we can compare expiryTime with nextRun using Sub() function.

Also, we came across with a case while rotating root cert every month, helm chart calculated the cronStr as 0 0 */23 * * (i.e. cron gets executed every 1st and 23rd day of the month). Our certificate didn't get rotated and was due expiration on 7th day of the month. Rotation didn't happen by the cronjob that ran on the 1st day of the month and the next run is in 23 days while the certificate is expiring in 6 days. So, to avoid this issue, we should also calculate if the cert is expiring before next-to-next cronjob run.

@junaid-ali junaid-ali linked a pull request Nov 29, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant