summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2023-05-12 12:35:26 +0200
committerNeal H. Walfield <neal@pep.foundation>2023-05-12 13:29:03 +0200
commitb84cd1384e7c3eff75c87a66fe1a18e0c815e413 (patch)
treeac22deb890291680e3335fe8d471733374165dc2
parentc1894b180ef3fea4d066f1fad242bd9bc6e2503c (diff)
openpgp: Improve error message.
- When an algorithm is completely disabled, don't say that it "is not considered secure since 1970-01-01T00:00:00Z" (i.e., the unix epoch), just say "is not considered secure". - Fixes #1000.
-rw-r--r--openpgp/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index a949403a..6f792c88 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -336,7 +336,13 @@ pub enum Error {
/// The optional time is the time at which the operation was
/// determined to no longer be secure.
#[error("{0} is not considered secure{}",
- .1.as_ref().map(|t| format!(" since {}", crate::fmt::time(t)))
+ .1.as_ref().map(|t| {
+ if *t == std::time::UNIX_EPOCH {
+ "".to_string()
+ } else {
+ format!(" since {}", crate::fmt::time(t))
+ }
+ })
.unwrap_or_else(|| "".into()))]
PolicyViolation(String, Option<std::time::SystemTime>),
}