From 289a412a123b547ccd13ac4554c5ebdd7f77be8c Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Sat, 8 Apr 2017 10:04:12 +0200 Subject: [PATCH] Check for private key when encryption is set --- TODO.md | 1 - src/repository/mod.rs | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index d67394e..f3c2678 100644 --- a/TODO.md +++ b/TODO.md @@ -12,7 +12,6 @@ ## Usability * Verbosity control -* Check for private key when encryption is set * Display backup name and path on backup integrity error * Better control over what is checked in `check` subcommand * Nice error when remote storage is not mounted diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 0ebe1d8..f93376a 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -167,6 +167,9 @@ impl Repository { #[inline] pub fn set_encryption(&mut self, public: Option<&PublicKey>) { if let Some(key) = public { + if !self.crypto.lock().unwrap().contains_secret_key(key) { + warn!("The secret key for that public key is not stored in the repository.") + } let mut key_bytes = Vec::new(); key_bytes.extend_from_slice(&key[..]); self.config.encryption = Some((EncryptionMethod::Sodium, key_bytes.into()))