From 6e1947d3b013aa26f336fbb00e403abaa1af4f20 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Thu, 21 Dec 2023 09:20:51 +1100 Subject: [PATCH] rename Tls.*_cert() to Tls.*_rota() actually this is a correction of the names of these fn these fn are actually handling trust_anchors rather than certificates and in some cases we will need equivalent fn for certificates --- libs/tls/src/cmd.rs | 4 ++-- libs/tls/src/lib.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/tls/src/cmd.rs b/libs/tls/src/cmd.rs index 78f2e67c4..03883eeae 100644 --- a/libs/tls/src/cmd.rs +++ b/libs/tls/src/cmd.rs @@ -21,7 +21,7 @@ pub fn shellchat<'a>( Some("deleteall") => { log::info!("starting TLS delete certificates"); let tls = Tls::new(); - let count = tls.del_all_cert().unwrap(); + let count = tls.del_all_rota().unwrap(); write!(ret, "{} {}", count, t!("tls.deleteall_done", locales::LANG)).ok(); log::info!("finished TLS delete certificates"); } @@ -62,7 +62,7 @@ pub fn shellchat<'a>( count = 0; let tls = Tls::new(); for rota in rotas { - tls.save_cert(&rota).unwrap_or_else(|e| log::warn!("{e}")); + tls.save_rota(&rota).unwrap_or_else(|e| log::warn!("{e}")); modals.update_progress(count).expect("no progress"); count += 1; } diff --git a/libs/tls/src/lib.rs b/libs/tls/src/lib.rs index 84f79370e..db191cf7b 100644 --- a/libs/tls/src/lib.rs +++ b/libs/tls/src/lib.rs @@ -84,7 +84,7 @@ impl Tls { .map(|i| &certificates[*i].1) .map(|x509| RustlsOwnedTrustAnchor::from(x509)) .for_each(|rota| { - self.save_cert(&rota).unwrap_or_else(|e| { + self.save_rota(&rota).unwrap_or_else(|e| { log::warn!("failed to save cert: {e}"); modals .show_notification( @@ -109,7 +109,7 @@ impl Tls { /// /// the number of trust-anchors deleted /// - pub fn del_all_cert(&self) -> Result { + pub fn del_all_rota(&self) -> Result { let count = match self.pddb.list_keys(TLS_TRUSTED_DICT, None) { Ok(list) => list.len(), Err(_) => 0, @@ -137,7 +137,7 @@ impl Tls { /// /// * `key` - the pddb-key containing the unwanted trust-anchor /// - pub fn del_cert(&self, key: &str) -> Result<(), Error> { + pub fn del_rota(&self, key: &str) -> Result<(), Error> { match self.pddb.delete_key(TLS_TRUSTED_DICT, key, None) { Ok(_) => { log::info!("Deleted {}:{}\n", TLS_TRUSTED_DICT, key); @@ -157,7 +157,7 @@ impl Tls { /// /// * `ta` - a trusted trust-anchor /// - pub fn save_cert(&self, ta: &RustlsOwnedTrustAnchor) -> Result<(), Error> { + pub fn save_rota(&self, ta: &RustlsOwnedTrustAnchor) -> Result<(), Error> { let key = ta.pddb_key(); match self.pddb.get( TLS_TRUSTED_DICT, @@ -206,7 +206,7 @@ impl Tls { /// /// * `key` - pddb key holding the trust-anchor /// - pub fn get_cert(&self, key: &str) -> Option { + pub fn get_rota(&self, key: &str) -> Option { match self.pddb.get( TLS_TRUSTED_DICT, key, @@ -250,7 +250,7 @@ impl Tls { match self.pddb.list_keys(TLS_TRUSTED_DICT, None) { Ok(list) => list .iter() - .map(|key| self.get_cert(&key)) + .map(|key| self.get_rota(&key)) .filter_map(|rota| rota) .collect::>(), Err(e) => { @@ -268,7 +268,7 @@ impl Tls { Ok(list) => { let rota = list .iter() - .map(|key| self.get_cert(&key)) + .map(|key| self.get_rota(&key)) .filter_map(|rota| rota) .map(|t| Into::::into(t)); root_store.add_trust_anchors(rota);