When failing to get a revocation signer, show the actual error.

- When we fail to get a signer for `sq key revoke`, `sq key subkey
    revoke`, or `sq key userid revoke` we don't print out the actual
    error.  This can be confusing.

  - Print the actual error.

  - See #250.
This commit is contained in:
Neal H. Walfield 2024-06-12 18:09:15 +02:00
parent 0e5c58ef05
commit 6f8b9074b1
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3

View File

@ -1,6 +1,5 @@
use std::sync::Arc;
use anyhow::anyhow;
use anyhow::Context;
use anyhow::Result;
@ -127,46 +126,40 @@ pub fn get_secret_signer<'a>(
][..]);
if let Some(secret) = secret {
if let Ok((key, _password)) = sq.get_primary_key(secret, flags) {
Ok((secret.clone(), key))
} else {
if ! sq.time_is_now {
return Err(anyhow!(
"\
match sq.get_primary_key(secret, flags) {
Ok((key, _password)) => Ok((secret.clone(), key)),
Err(err) => {
if ! sq.time_is_now {
return Err(err.context(format!("\
No certification key found: the key specified with --revocation-file \
does not contain a certification key with secret key material. \
Perhaps this is because no certification keys are valid at the time \
you specified ({})",
DateTime::<Utc>::from(sq.time)
));
} else {
return Err(anyhow!(
"\
DateTime::<Utc>::from(sq.time))));
} else {
return Err(err.context(format!("\
No certification key found: the key specified with --revocation-file \
does not contain a certification key with secret key material"
));
does not contain a certification key with secret key material")));
}
}
}
} else {
if let Ok((key, _password)) = sq.get_primary_key(cert, flags) {
Ok((cert.clone(), key))
} else {
if ! sq.time_is_now {
return Err(anyhow!(
"\
match sq.get_primary_key(cert, flags) {
Ok((key, _password)) => Ok((cert.clone(), key)),
Err(err) => {
if ! sq.time_is_now {
return Err(err.context(format!("\
No certification key found: --revocation-file not provided and the
certificate to revoke does not contain a certification key with secret
key material. Perhaps this is because no certification keys are valid at
the time you specified ({})",
DateTime::<Utc>::from(sq.time)
));
} else {
return Err(anyhow!(
"\
DateTime::<Utc>::from(sq.time))));
} else {
return Err(err.context(format!("\
No certification key found: --revocation-file not provided and the
certificate to revoke does not contain a certification key with secret
key material"
));
key material")));
}
}
}
}