mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Check for leap year, and adjust the date accordingly
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -238,6 +238,9 @@ bool generate_certificate(const char* certfile, bool rsa, const char *domain)
|
||||
char not_after[16] = { 0 };
|
||||
strftime(not_before, sizeof(not_before), "%Y%m%d%H%M%S", tm);
|
||||
tm->tm_year += 30; // 30 years from now
|
||||
// Check for leap year, and adjust the date accordingly
|
||||
const bool isLeapYear = tm->tm_year % 4 == 0 && (tm->tm_year % 100 != 0 || tm->tm_year % 400 == 0);
|
||||
tm->tm_mday = tm->tm_mon == 2 && tm->tm_mday == 29 && !isLeapYear ? 28 : tm->tm_mday;
|
||||
strftime(not_after, sizeof(not_after), "%Y%m%d%H%M%S", tm);
|
||||
|
||||
// 1. Create CA certificate
|
||||
|
||||
Reference in New Issue
Block a user