Implement 'introducer remove'
- Implement the subcommand `remove` for `introducer`. - Remove the introducer by adding a certification with trust level 1 and trust depth 0. - Move `crypt.rs` into `common/` and add a generic authenticaton function to be used by `introducer add` and `... remove`.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use sequoia_openpgp::{Fingerprint, KeyHandle};
|
||||
use sequoia_openpgp::cert::ValidCert;
|
||||
use sequoia_cert_store::Store;
|
||||
|
||||
use crate::cli::cli_args::IntroducerRemoveCommand;
|
||||
@@ -23,6 +24,19 @@ pub async fn dispatch(cmd: IntroducerRemoveCommand, config: HuskConfigContainer)
|
||||
let certs = cert_store.lookup_by_cert(&KeyHandle::try_from(&fpr)?)
|
||||
.map_err(|_| CommandError::CertNotFound(fpr.clone()))?;
|
||||
|
||||
// Filter out valid certificates. If the certificate is not
|
||||
// valid according to the policy, it is already no introducer.
|
||||
let certs: Vec<ValidCert> = certs.iter()
|
||||
.filter_map(|c|
|
||||
c.with_policy(policy, None).ok()
|
||||
)
|
||||
.collect();
|
||||
|
||||
if let Some(cert) = certs.first() {
|
||||
Introducer::remove(&context, cert, cmd.demote)?;
|
||||
} else {
|
||||
return Err(CommandError::CertNotFound(fpr).into());
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user