Skip to content

Commit 0b28255

Browse files
committed
Re-read agent.toml on ACME retry in bootroot-agent
After secrets are rotated and OpenBao Agent renders new values to agent.toml, the ACME retry loop previously reused stale in-memory config. Each retry attempt now re-reads config from disk so that freshly rendered credentials (EAB, HMAC) are picked up without restarting the daemon. The default retry backoff window is also extended from [5, 10, 30] s (45 s total) to [5, 10, 30, 60] s (105 s total), giving at least one full static_secret_render_interval cycle (30 s) of headroom before retries are exhausted. Closes #303
1 parent 6b43acd commit 0b28255

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ mod tests {
292292
assert_eq!(settings.acme.directory_fetch_max_delay_secs, 10);
293293
assert_eq!(settings.acme.poll_attempts, 15);
294294
assert_eq!(settings.acme.poll_interval_secs, 2);
295-
assert_eq!(settings.retry.backoff_secs, vec![5, 10, 30]);
295+
assert_eq!(settings.retry.backoff_secs, vec![5, 10, 30, 60]);
296296
assert_eq!(settings.scheduler.max_concurrent_issuances, 3);
297297
assert!(!settings.trust.verify_certificates);
298298

src/config/defaults.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const DEFAULT_DIRECTORY_FETCH_BASE_DELAY_SECS: u64 = 1;
1717
const DEFAULT_DIRECTORY_FETCH_MAX_DELAY_SECS: u64 = 10;
1818
const DEFAULT_POLL_ATTEMPTS: u64 = 15;
1919
const DEFAULT_POLL_INTERVAL_SECS: u64 = 2;
20-
const DEFAULT_RETRY_BACKOFF_SECS: [u64; 3] = [5, 10, 30];
20+
const DEFAULT_RETRY_BACKOFF_SECS: [u64; 4] = [5, 10, 30, 60];
2121
const DEFAULT_HOOK_TIMEOUT_SECS: u64 = 30;
2222
const DEFAULT_MAX_CONCURRENT_ISSUANCES: u64 = 3;
2323
const DEFAULT_VERIFY_CERTIFICATES: bool = false;

src/daemon.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,30 @@ async fn issue_with_retry(
257257
settings: &config::Settings,
258258
profile: &config::DaemonProfileSettings,
259259
eab: Option<eab::EabCredentials>,
260+
config_path: &Path,
260261
) -> anyhow::Result<()> {
261262
let backoff = select_retry_backoff(settings, profile);
263+
let profile_domain = config::profile_domain(settings, profile);
264+
let config_path_owned = config_path.to_path_buf();
262265
issue_with_retry_inner(
263-
|| acme::issue_certificate(settings, profile, eab.clone()),
266+
|| {
267+
let path = config_path_owned.clone();
268+
let domain = profile_domain.clone();
269+
let eab = eab.clone();
270+
async move {
271+
let fresh = config::Settings::new(Some(path))?;
272+
let fresh_profile = fresh
273+
.profiles
274+
.iter()
275+
.find(|p| config::profile_domain(&fresh, p) == domain)
276+
.ok_or_else(|| {
277+
anyhow::anyhow!("Profile '{domain}' not found in reloaded config")
278+
})?
279+
.clone();
280+
let fresh_eab = profile::resolve_profile_eab(&fresh_profile, eab);
281+
acme::issue_certificate(&fresh, &fresh_profile, fresh_eab).await
282+
}
283+
},
264284
|duration| tokio::time::sleep(duration),
265285
backoff,
266286
)
@@ -377,7 +397,7 @@ async fn check_and_renew_profile(
377397
);
378398
let _permit = semaphore.acquire().await?;
379399
let profile_eab = profile::resolve_profile_eab(profile, default_eab);
380-
match issue_with_retry(settings, profile, profile_eab).await {
400+
match issue_with_retry(settings, profile, profile_eab, &hardening.config_path).await {
381401
Ok(()) => {
382402
maybe_harden_tls_verify(
383403
settings,

0 commit comments

Comments
 (0)