| 1 |
//! Command-line parser for `sq pki vouch add`. |
| 2 |
|
| 3 |
use clap::Parser; |
| 4 |
|
| 5 |
use crate::cli::THIRD_PARTY_CERTIFICATION_VALIDITY_IN_YEARS; |
| 6 |
|
| 7 |
use crate::cli::types::ClapData; |
| 8 |
use crate::cli::types::expiration; |
| 9 |
use crate::cli::types::ExpirationArg; |
| 10 |
use crate::cli::types::FileOrStdout; |
| 11 |
use crate::cli::types::TrustAmount; |
| 12 |
use crate::cli::types::UserIDDesignators; |
| 13 |
use crate::cli::types::cert_designator::{self, *}; |
| 14 |
use crate::cli::types::userid_designator; |
| 15 |
|
| 16 |
use crate::cli::examples::*; |
| 17 |
|
| 18 |
const ADD_EXAMPLES: Actions = Actions { |
| 19 |
actions: &[ |
| 20 |
Action::setup().command(&[ |
| 21 |
"sq", "key", "import", |
| 22 |
"alice-secret.pgp", |
| 23 |
]).build(), |
| 24 |
|
| 25 |
Action::example().comment( |
| 26 |
"Alice certifies that Bob controls 3F68CB84CE537C9A and [email protected].", |
| 27 |
).command(&[ |
| 28 |
"sq", "pki", "vouch", "add", |
| 29 |
"--certifier=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 30 |
"--cert=511257EBBF077B7AEDAE5D093F68CB84CE537C9A", |
| 31 |
"[email protected]", |
| 32 |
]).build(), |
| 33 |
|
| 34 |
Action::example().comment( |
| 35 |
"Alice certifies that Bob controls 3F68CB84CE537C9A and [email protected], \ |
| 36 |
which is not a self-signed user ID.", |
| 37 |
).command(&[ |
| 38 |
"sq", "pki", "vouch", "add", |
| 39 |
"--certifier=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 40 |
"--cert=511257EBBF077B7AEDAE5D093F68CB84CE537C9A", |
| 41 |
"[email protected]", |
| 42 |
]).build(), |
| 43 |
], |
| 44 |
}; |
| 45 |
test_examples!(sq_pki_vouch_add, ADD_EXAMPLES); |
| 46 |
|
| 47 |
#[derive(Parser, Debug)] |
| 48 |
#[clap( |
| 49 |
name = "add", |
| 50 |
about = "Certify a User ID for a Certificate", |
| 51 |
long_about = format!( |
| 52 |
"Certify a User ID for a Certificate |
| 53 |
|
| 54 |
Using a certification a keyholder may vouch for the fact that another \ |
| 55 |
certificate legitimately belongs to a user id. In the context of \ |
| 56 |
emails this means that the same entity controls the key and the email \ |
| 57 |
address. These kind of certifications form the basis for the Web of \ |
| 58 |
Trust. |
| 59 |
|
| 60 |
This command emits the certificate with the new certification. The \ |
| 61 |
updated certificate has to be distributed, preferably by sending it to \ |
| 62 |
the certificate holder for approval. See also `sq key approvals`. |
| 63 |
|
| 64 |
By default a certification expires after {} years. \ |
| 65 |
Using the `--expiration` argument specific validity periods may be defined. \ |
| 66 |
It allows for providing a point in time for validity to end or a validity \ |
| 67 |
duration. |
| 68 |
|
| 69 |
`sq pki vouch add` respects the reference time set by the top-level \ |
| 70 |
`--time` argument. It sets the certification's creation time to the \ |
| 71 |
reference time. |
| 72 |
", |
| 73 |
THIRD_PARTY_CERTIFICATION_VALIDITY_IN_YEARS, |
| 74 |
), |
| 75 |
after_help = ADD_EXAMPLES, |
| 76 |
)] |
| 77 |
pub struct Command { |
| 78 |
#[command(flatten)] |
| 79 |
pub certifier: CertDesignators<CertUserIDEmailFileSelfArgs, |
| 80 |
CertifierPrefix, |
| 81 |
OneValue, |
| 82 |
CertifierDoc>, |
| 83 |
|
| 84 |
#[command(flatten)] |
| 85 |
pub cert: CertDesignators< |
| 86 |
cert_designator::CertFileArgs, |
| 87 |
cert_designator::CertPrefix, |
| 88 |
cert_designator::OneValue>, |
| 89 |
|
| 90 |
#[command(flatten)] |
| 91 |
pub userids: UserIDDesignators< |
| 92 |
userid_designator::AllExactByAndAddArgs>, |
| 93 |
|
| 94 |
#[clap( |
| 95 |
long = "amount", |
| 96 |
value_name = "AMOUNT", |
| 97 |
default_value = "full", |
| 98 |
help = "Set the amount of trust", |
| 99 |
long_help = "Set the amount of trust |
| 100 |
|
| 101 |
Values between 1 and 120 are meaningful. \ |
| 102 |
120 means fully trusted. Values less than 120 indicate the degree \ |
| 103 |
of trust. 60 is usually used for partially trusted.", |
| 104 |
)] |
| 105 |
pub amount: TrustAmount<u8>, |
| 106 |
|
| 107 |
#[command(flatten)] |
| 108 |
pub expiration: ExpirationArg<expiration::CertificationKind>, |
| 109 |
|
| 110 |
/// Workaround for https://github.com/clap-rs/clap/issues/3846 |
| 111 |
#[clap(skip)] |
| 112 |
pub expiration_source: Option<clap::parser::ValueSource>, |
| 113 |
|
| 114 |
#[clap( |
| 115 |
long = "local", |
| 116 |
help = "Make the certification a local certification", |
| 117 |
long_help = "Make the certification a local certification |
| 118 |
|
| 119 |
Normally, local certifications are not exported.", |
| 120 |
)] |
| 121 |
pub local: bool, |
| 122 |
#[clap( |
| 123 |
long = "non-revocable", |
| 124 |
help = "Mark the certification as being non-revocable", |
| 125 |
long_help = |
| 126 |
"Mark the certification as being non-revocable |
| 127 |
|
| 128 |
That is, you cannot later revoke this \ |
| 129 |
certification. This should normally only \ |
| 130 |
be used with an expiration.", |
| 131 |
)] |
| 132 |
pub non_revocable: bool, |
| 133 |
|
| 134 |
#[command(flatten)] |
| 135 |
pub signature_notations: crate::cli::types::SignatureNotationsArg, |
| 136 |
|
| 137 |
#[clap( |
| 138 |
help = FileOrStdout::HELP_OPTIONAL, |
| 139 |
long, |
| 140 |
value_name = FileOrStdout::VALUE_NAME, |
| 141 |
)] |
| 142 |
pub output: Option<FileOrStdout>, |
| 143 |
} |