From 1686be894a8d152ce6915afbee9cce45269a6195 Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Thu, 23 May 2024 17:18:49 +0200 Subject: [PATCH] fix: allow ManualTrustRoot to have multiple rekor keys `ManualTrustRoot` implements the `TrustRoot` trait, which requires the implemented to have multiple rekor keys. The `ManualTrustRoot` struct has now been updated to handle that, prior to that only one Rekor key was stored inside of a `ManualTrustRoot` instance. Signed-off-by: Flavio Castelli --- examples/cosign/verify/main.rs | 14 ++++++-------- src/lib.rs | 4 ++-- src/trust/mod.rs | 14 ++++---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/examples/cosign/verify/main.rs b/examples/cosign/verify/main.rs index ad8b1555d9..91112ec694 100644 --- a/examples/cosign/verify/main.rs +++ b/examples/cosign/verify/main.rs @@ -63,11 +63,11 @@ struct Cli { /// File containing Rekor's public key (e.g.: ~/.sigstore/root/targets/rekor.pub) #[clap(long, required(false))] - rekor_pub_key: Option, + rekor_pub_keys: Vec, /// File containing Fulcio's certificate (e.g.: ~/.sigstore/root/targets/fulcio.crt.pem) #[clap(long, required(false))] - fulcio_cert: Option, + fulcio_certs: Vec, /// The issuer of the OIDC token used by the user to authenticate against Fulcio #[clap(long, required(false))] @@ -235,14 +235,14 @@ async fn fulcio_and_rekor_data(cli: &Cli) -> anyhow::Result anyhow::Result { - pub fulcio_certs: Option>>, - pub rekor_key: Option>, + pub fulcio_certs: Vec>, + pub rekor_keys: Vec>, pub ctfe_keys: Vec>, } impl TrustRoot for ManualTrustRoot<'_> { fn fulcio_certs(&self) -> crate::errors::Result> { - Ok(match &self.fulcio_certs { - Some(certs) => certs.clone(), - None => Vec::new(), - }) + Ok(self.fulcio_certs.clone()) } fn rekor_keys(&self) -> crate::errors::Result> { - Ok(match &self.rekor_key { - Some(key) => vec![&key[..]], - None => Vec::new(), - }) + Ok(self.rekor_keys.iter().map(|key| &key[..]).collect()) } fn ctfe_keys(&self) -> crate::errors::Result> {