diff --git a/src/commands/network.rs b/src/commands/network.rs index 7a3d3e6c..558111e5 100644 --- a/src/commands/network.rs +++ b/src/commands/network.rs @@ -927,6 +927,8 @@ pub fn dispatch_search(mut sq: Sq, c: cli::network::search::Command) let rt = tokio::runtime::Runtime::new()?; rt.block_on(async { for _ in 0..iterations { + let cert_store = sq.cert_store()?; + let mut requests = JoinSet::new(); let mut converged = true; std::mem::take(&mut queries).into_iter().for_each(|query| { @@ -1024,7 +1026,7 @@ pub fn dispatch_search(mut sq: Sq, c: cli::network::search::Command) // Finally, we also consult the certificate store to // discover more identifiers. This is sync, but we use // the same mechanism to merge the result back in. - if let Ok(Some(store)) = sq.cert_store() { + if let Some(store) = &cert_store { pb.inc_length(1); let mut email_query = UserIDQueryParams::new(); email_query.set_email(true); diff --git a/src/commands/verify.rs b/src/commands/verify.rs index 4310850c..02f1439d 100644 --- a/src/commands/verify.rs +++ b/src/commands/verify.rs @@ -181,7 +181,7 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> { } } - fn print_sigs(&mut self, results: &[VerificationResult]) { + fn print_sigs(&mut self, results: &[VerificationResult]) -> Result<()> { make_qprintln!(self.quiet); use crate::common::pki::output::print_path; use crate::print_error_chain; @@ -265,7 +265,7 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> { qprintln!("Authenticating {} ({:?}) using the web of trust:", cert_fpr, signer_userid); - if let Ok(Some(cert_store)) = self.sq.cert_store() { + if let Some(cert_store) = self.sq.cert_store()? { // Build the network. let cert_store = sequoia_wot::store::CertStore::from_store( cert_store, self.sq.policy, reference_time); @@ -432,6 +432,8 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> { qprintln!(""); } + + Ok(()) } } @@ -514,8 +516,9 @@ impl<'c, 'store, 'rstore> VerificationHelper for VHelper<'c, 'store, 'rstore> qprintln!("Encrypted using {}", sym_algo); } }, - MessageLayer::SignatureGroup { ref results } => - self.print_sigs(results), + MessageLayer::SignatureGroup { ref results } => { + self.print_sigs(results)?; + }, } } diff --git a/src/sq.rs b/src/sq.rs index 15f5ee87..22ac0799 100644 --- a/src/sq.rs +++ b/src/sq.rs @@ -456,18 +456,18 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> { /// Returns the secret keys found in any specified keyrings. pub fn keyring_tsks(&self) - -> &BTreeMap)> + -> Result<&BTreeMap)>> { if let Some(keyring_tsks) = self.keyring_tsks.get() { - keyring_tsks + Ok(keyring_tsks) } else { // This also initializes keyring_tsks. - let _ = self.cert_store(); + self.cert_store()?; // If something went wrong, we just set it to an empty // map. - self.keyring_tsks.get_or_init(|| BTreeMap::new()) + Ok(self.keyring_tsks.get_or_init(|| BTreeMap::new())) } } @@ -1293,7 +1293,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> { let try_keyrings = |cert: &Cert, key: &Key<_, _>| -> Result<_> { - let keyring_tsks = self.keyring_tsks(); + let keyring_tsks = self.keyring_tsks()?; if let Some((cert_fpr, key)) = keyring_tsks.get(&key.fingerprint()) { @@ -1353,7 +1353,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> { let try_keyrings = |cert: &Cert, key: &Key<_, _>| -> Result<_> { - let keyring_tsks = self.keyring_tsks(); + let keyring_tsks = self.keyring_tsks()?; if let Some((cert_fpr, key)) = keyring_tsks.get(&key.fingerprint()) {