| 1 |
//! Command-line parser for `sq pki vouch replay`. |
| 2 |
|
| 3 |
use clap::Parser; |
| 4 |
|
| 5 |
use crate::cli::types::CertDesignators; |
| 6 |
use crate::cli::types::ClapData; |
| 7 |
use crate::cli::types::FileOrStdout; |
| 8 |
use crate::cli::types::cert_designator; |
| 9 |
|
| 10 |
use crate::cli::examples::*; |
| 11 |
|
| 12 |
const REPLAY_EXAMPLES: Actions = Actions { |
| 13 |
actions: &[ |
| 14 |
Action::setup().command(&[ |
| 15 |
"sq", "key", "import", |
| 16 |
"alice-secret.pgp", |
| 17 |
]).build(), |
| 18 |
|
| 19 |
Action::setup().command(&[ |
| 20 |
"sq", "key", "import", |
| 21 |
"alice-new-secret.pgp", |
| 22 |
]).build(), |
| 23 |
|
| 24 |
Action::setup().command(&[ |
| 25 |
"sq", "pki", "vouch", "add", |
| 26 |
"--certifier=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 27 |
"--cert=511257EBBF077B7AEDAE5D093F68CB84CE537C9A", |
| 28 |
"[email protected]", |
| 29 |
]).build(), |
| 30 |
|
| 31 |
Action::example().comment( |
| 32 |
"Alice generates a new certificate, and replays the certifications \ |
| 33 |
she made with the old certificate using the new one.", |
| 34 |
).command(&[ |
| 35 |
"sq", "pki", "vouch", "replay", |
| 36 |
"--source=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 37 |
"--target=C5999E8191BF7B503653BE958B1F7910D01F86E5", |
| 38 |
]).build(), |
| 39 |
], |
| 40 |
}; |
| 41 |
test_examples!(sq_pki_vouch_replay, REPLAY_EXAMPLES); |
| 42 |
|
| 43 |
#[derive(Parser, Debug)] |
| 44 |
#[clap( |
| 45 |
name = "replay", |
| 46 |
about = "Replays vouches", |
| 47 |
long_about = format!( |
| 48 |
"Replays vouches |
| 49 |
|
| 50 |
This command replays the vouches made by one certificate using another \ |
| 51 |
certificate. This is primarily useful when you replace a certificate, \ |
| 52 |
and you want the new certificate to have made the same certifications \ |
| 53 |
as you made with the old certificate. |
| 54 |
|
| 55 |
Because certifications are associated with the certificated \ |
| 56 |
certificate, and not the certifier's certificate, this may not replay \ |
| 57 |
all of the certifications that the source ever made. |
| 58 |
|
| 59 |
This command only copies the active certification for a given user ID \ |
| 60 |
and certificate. This includes both exportable certifications \ |
| 61 |
(vouches) as well as non-exportable certifications (links). It \ |
| 62 |
excludes expired certifications. It also doesn't replay \ |
| 63 |
certifications made on invalid, expired or revoked certificates, or \ |
| 64 |
revoked user IDs. |
| 65 |
|
| 66 |
This command replays all of the certifications parameters including \ |
| 67 |
any expiration time, but the creation time is set to the current time. |
| 68 |
|
| 69 |
Stable since 1.2.0. |
| 70 |
", |
| 71 |
), |
| 72 |
after_help = REPLAY_EXAMPLES, |
| 73 |
)] |
| 74 |
pub struct Command { |
| 75 |
#[command(flatten)] |
| 76 |
pub source: CertDesignators<cert_designator::CertUserIDEmailFileArgs, |
| 77 |
cert_designator::SourcePrefix, |
| 78 |
cert_designator::OneValue>, |
| 79 |
#[command(flatten)] |
| 80 |
pub target: CertDesignators<cert_designator::CertUserIDEmailFileArgs, |
| 81 |
cert_designator::TargetPrefix, |
| 82 |
cert_designator::OneValue>, |
| 83 |
|
| 84 |
#[clap( |
| 85 |
long, |
| 86 |
help = "\ |
| 87 |
Don't check that the source and target share a self-signed user ID", |
| 88 |
long_help = "\ |
| 89 |
Don't check that the source and target share a self-signed user ID |
| 90 |
|
| 91 |
Normally, this command checks that the source and target certificates |
| 92 |
have a user ID in common. This flag skips that check.", |
| 93 |
)] |
| 94 |
pub allow_dissimilar_userids: bool, |
| 95 |
|
| 96 |
#[clap( |
| 97 |
help = FileOrStdout::HELP_OPTIONAL, |
| 98 |
long, |
| 99 |
value_name = FileOrStdout::VALUE_NAME, |
| 100 |
)] |
| 101 |
pub output: Option<FileOrStdout>, |
| 102 |
} |