summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2022-01-14 13:13:34 +0100
committerNeal H. Walfield <neal@pep.foundation>2022-01-14 14:17:18 +0100
commitb964e6bc05b8d3b143d863330ddf61b85ab27f8c (patch)
treee020711210fbc369b73aeb279dbbd9960ccba7ec
parentd9c482b441e0b6f9becd09791061a3a54b1c7aba (diff)
sq: Improve sq inspect's output for revocation certificates.
- Show the revocation certificate's human-readable revocation message, if any. - If the revocation certificate is a third-party revocation, then also show the first issuer.
-rw-r--r--sq/src/commands/inspect.rs32
1 files changed, 28 insertions, 4 deletions
diff --git a/sq/src/commands/inspect.rs b/sq/src/commands/inspect.rs
index 2d2037a9..f1fcfc35 100644
--- a/sq/src/commands/inspect.rs
+++ b/sq/src/commands/inspect.rs
@@ -283,14 +283,38 @@ fn inspect_revocation(output: &mut dyn io::Write,
-> Result<()> {
use crate::openpgp::types::RevocationStatus::*;
fn print_reasons(output: &mut dyn io::Write, indent: &str,
- sigs: &[&Signature])
+ third_party: bool, sigs: &[&Signature])
-> Result<()> {
for sig in sigs {
- if let Some((r, _)) = sig.reason_for_revocation() {
+ if let Some((r, msg)) = sig.reason_for_revocation() {
writeln!(output, "{} - {}", indent, r)?;
+ if third_party {
+ writeln!(output, "{} Issued by {}",
+ indent,
+ if let Some(issuer)
+ = sig.get_issuers().into_iter().next()
+ {
+ issuer.to_string()
+ } else {
+ "an unknown certificate".into()
+ })?;
+ }
+ writeln!(output, "{} Message: {:?}",
+ indent, String::from_utf8_lossy(msg))?;
} else {
writeln!(output, "{} - No reason specified",
indent)?;
+ if third_party {
+ writeln!(output, "{} Issued by {}",
+ indent,
+ if let Some(issuer)
+ = &sig.get_issuers().into_iter().next()
+ {
+ issuer.to_string()
+ } else {
+ "an unknown certificate".into()
+ })?;
+ }
}
}
Ok(())
@@ -298,11 +322,11 @@ fn inspect_revocation(output: &mut dyn io::Write,
match revoked {
Revoked(sigs) => {
writeln!(output, "{} Revoked:", indent)?;
- print_reasons(output, indent, &sigs)?;
+ print_reasons(output, indent, false, &sigs)?;
},
CouldBe(sigs) => {
writeln!(output, "{} Possibly revoked:", indent)?;
- print_reasons(output, indent, &sigs)?;
+ print_reasons(output, indent, true, &sigs)?;
},
NotAsFarAsWeKnow => (),
}