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

2
Cargo.lock generated
View file

@ -3140,7 +3140,7 @@ dependencies = [
[[package]] [[package]]
name = "wstunnel" name = "wstunnel"
version = "10.0.2" version = "10.0.1"
dependencies = [ dependencies = [
"ahash", "ahash",
"anyhow", "anyhow",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "wstunnel" name = "wstunnel"
version = "10.0.2" version = "10.0.1"
edition = "2021" edition = "2021"
repository = "https://github.com/erebe/wstunnel.git" repository = "https://github.com/erebe/wstunnel.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

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