From 4164274ad2ff8f9f159ae513fb2245b5816df334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Mon, 10 Apr 2023 11:18:11 +0200 Subject: [PATCH] Check keys at least every 3 hours Doing so will permit to regularly populate the revocation file with the new entries. --- src/key.rs | 4 ++-- src/main.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/key.rs b/src/key.rs index 651f1a3..dcd8efe 100644 --- a/src/key.rs +++ b/src/key.rs @@ -46,9 +46,9 @@ pub async fn key_rotation(db: &SqlitePool, cnf: &Config) -> Duration { durations.push(d); } } + durations.push(Duration::from_secs(crate::KEY_CHECK_MIN_DELAY)); durations.sort(); - durations.reverse(); - durations.pop().unwrap_or(Duration::from_secs(3600)) + durations[durations.len() - 1] } async fn renew_key_if_expired( diff --git a/src/main.rs b/src/main.rs index cfdfc8a..c878920 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,7 @@ const DEFAULT_CNF_KEY_DB: &str = "key-db.sqlite3"; const DEFAULT_CNF_REVOCATION: u64 = 1728000; const DEFAULT_LIB_DIR: &str = env!("VARLIBDIR"); const DEFAULT_MSG_SIZE: usize = 1024 * 1024; +const KEY_CHECK_MIN_DELAY: u64 = 60 * 60 * 3; const LOG_LEVEL_ENV_VAR: &str = "OPENSMTPD_FILTER_DKIMOUT_LOG_LEVEL"; #[macro_export]