avoid overflow of day depending of the month

This commit is contained in:
Σrebe - Romain GERARD 2024-08-27 10:13:06 +02:00
parent fc729a0739
commit 8dcaf17356
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
3 changed files with 4 additions and 4 deletions

View file

@ -15,13 +15,13 @@ pub static TLS_CERTIFICATE: LazyLock<(Vec<CertificateDer<'static>>, PrivateKeyDe
let el = now.elapsed();
let year = 2024 - (el.as_nanos() % 2) as i32;
let month = 1 + (el.as_nanos() % 12) as u8;
let day = 1 + (el.as_nanos() % 31) as u8;
let day = 1 + (el.as_nanos() % 28) as u8;
cert.not_before = date_time_ymd(year, month, day);
let el = now.elapsed();
let year = 2024 + (el.as_nanos() % 50) as i32;
let month = 1 + (el.as_nanos() % 12) as u8;
let day = 1 + (el.as_nanos() % 31) as u8;
let day = 1 + (el.as_nanos() % 28) as u8;
cert.not_after = date_time_ymd(year, month, day);
let cert = cert.self_signed(&key_pair).unwrap().der().clone();