From 8dcaf17356e56ee2e1e02173ca5428ad1f7c3c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Tue, 27 Aug 2024 10:13:06 +0200 Subject: [PATCH] avoid overflow of day depending of the month --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/embedded_certificate.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 590dcd2..c223a6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3140,7 +3140,7 @@ dependencies = [ [[package]] name = "wstunnel" -version = "10.0.2" +version = "10.0.1" dependencies = [ "ahash", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 9af2aa6..9ce2ef8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wstunnel" -version = "10.0.2" +version = "10.0.1" edition = "2021" repository = "https://github.com/erebe/wstunnel.git" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/embedded_certificate.rs b/src/embedded_certificate.rs index 0ba6cbc..3bcd3ed 100644 --- a/src/embedded_certificate.rs +++ b/src/embedded_certificate.rs @@ -15,13 +15,13 @@ pub static TLS_CERTIFICATE: LazyLock<(Vec>, 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();