From 4e092d0ef65b6d7440ef71edfa25bbe8379f1eb6 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 15:15:06 +0000 Subject: [PATCH] fix(automation): sign_trust deduplicates certificates with a set Each imported certificate was compared with every one already collected, quadratic in a bundle of many distinct certificates. --- crates/automation/src/signing.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/automation/src/signing.rs b/crates/automation/src/signing.rs index 743a36ff56..56a96511e4 100644 --- a/crates/automation/src/signing.rs +++ b/crates/automation/src/signing.rs @@ -309,6 +309,9 @@ impl Automation { pub(crate) fn sign_trust(&mut self, a: &Args) -> Result { let mut certs: Vec = if a.opt_bool("clear")?.unwrap_or(false) { Vec::new() } else { self.session.trusted_certificates().to_vec() }; + // Which certificates are already in, by their bytes: a set, so a bundle of many distinct + // certificates isn't compared against every one before it. + let mut known: std::collections::HashSet> = certs.iter().map(|c| c.raw.clone()).collect(); let paths: Vec = match a.get("paths") { None => Vec::new(), Some(v) => v @@ -329,7 +332,7 @@ impl Automation { sign::x509::load_certificates(&bytes).map_err(failed)? }; for c in found { - if !certs.iter().any(|t| t.raw == c.raw) { + if known.insert(c.raw.clone()) { certs.push(c); } }