| 1 |
use clap::Parser; |
| 2 |
|
| 3 |
use sequoia_openpgp as openpgp; |
| 4 |
use openpgp::KeyHandle; |
| 5 |
|
| 6 |
use crate::cli::examples; |
| 7 |
use examples::Action; |
| 8 |
use examples::Actions; |
| 9 |
|
| 10 |
use crate::cli::types::UserIDDesignators; |
| 11 |
use crate::cli::types::userid_designator; |
| 12 |
|
| 13 |
use super::CertificationNetworkArg; |
| 14 |
use super::RequiredTrustAmountArg; |
| 15 |
|
| 16 |
/// Verify the specified path |
| 17 |
/// |
| 18 |
/// A path is a sequence of certificates starting at the root, and |
| 19 |
/// a User ID. This function checks that each path segment has a |
| 20 |
/// valid certification, which also satisfies any constraints |
| 21 |
/// (trust amount, trust depth, regular expressions). |
| 22 |
/// |
| 23 |
/// If a valid path is not found, then this subcommand also lints |
| 24 |
/// the path. In particular, it report if any certifications are |
| 25 |
/// insufficient, e.g., not enough trust depth, or invalid, e.g., |
| 26 |
/// because they use SHA-1, but the use of SHA-1 has been |
| 27 |
/// disabled. |
| 28 |
#[derive(Parser, Debug)] |
| 29 |
#[clap( |
| 30 |
name = "path", |
| 31 |
after_help = EXAMPLES, |
| 32 |
)] |
| 33 |
pub struct Command { |
| 34 |
#[clap( |
| 35 |
value_name = "FINGERPRINT|KEYID", |
| 36 |
required = true, |
| 37 |
num_args = 1.., |
| 38 |
help = "The path to authenticate", |
| 39 |
long_help = "\ |
| 40 |
The path to authenticate |
| 41 |
|
| 42 |
A path consists of one or more certificates. The first certificate is \ |
| 43 |
the root, and the last certificate is the one being authenticated for \ |
| 44 |
the specified user ID. |
| 45 |
", |
| 46 |
)] |
| 47 |
pub path: Vec<KeyHandle>, |
| 48 |
|
| 49 |
#[command(flatten)] |
| 50 |
pub userids: UserIDDesignators< |
| 51 |
userid_designator::PlainAddAndByArgs, |
| 52 |
userid_designator::OneValueNoLinting, |
| 53 |
Documentation>, |
| 54 |
|
| 55 |
#[command(flatten)] |
| 56 |
pub certification_network: CertificationNetworkArg, |
| 57 |
|
| 58 |
#[command(flatten)] |
| 59 |
pub trust_amount: RequiredTrustAmountArg, |
| 60 |
} |
| 61 |
|
| 62 |
/// Documentation for the user ID designators. |
| 63 |
#[derive(Debug, Clone)] |
| 64 |
pub struct Documentation(()); |
| 65 |
|
| 66 |
impl userid_designator::Documentation for Documentation { |
| 67 |
fn help(typ: userid_designator::UserIDDesignatorType, |
| 68 |
_plain: bool, |
| 69 |
semantics: userid_designator::UserIDDesignatorSemantics) |
| 70 |
-> (&'static str, Option<&'static str>) |
| 71 |
{ |
| 72 |
use userid_designator::UserIDDesignatorType::*; |
| 73 |
use userid_designator::UserIDDesignatorSemantics::*; |
| 74 |
match (typ, semantics) { |
| 75 |
(UserID, _) => { |
| 76 |
("Authenticate the specified user ID", |
| 77 |
Some("\ |
| 78 |
Authenticate the specified user ID |
| 79 |
|
| 80 |
The specified user ID does not need to be self signed.")) |
| 81 |
} |
| 82 |
(Email, Add | Exact) => { |
| 83 |
("Authenticate the specified email address", |
| 84 |
Some("\ |
| 85 |
Authenticate the specified email address |
| 86 |
|
| 87 |
This checks whether it is possible to authenticate the user ID \ |
| 88 |
consisting of just specified email address. The user ID does \ |
| 89 |
not need to be self signed.")) |
| 90 |
} |
| 91 |
(Email, By) => { |
| 92 |
("\ |
| 93 |
Authenticate the self-signed user ID with the specified email address", |
| 94 |
Some("\ |
| 95 |
Authenticate the self-signed user ID with the specified email address |
| 96 |
|
| 97 |
This checks whether it is possible to authenticate the self-signed \ |
| 98 |
user ID with the specified email address. |
| 99 |
|
| 100 |
If the certificate is invalid or there is no self-signed user ID with \ |
| 101 |
the specified email address, uses a user ID with just the email \ |
| 102 |
address.")) |
| 103 |
} |
| 104 |
(Name, _) => { |
| 105 |
("Authenticate the specified display name", |
| 106 |
Some("\ |
| 107 |
Authenticate the specified display name |
| 108 |
|
| 109 |
This checks whether it is possible to authenticate a user ID with the \ |
| 110 |
specified display name. The user IDs do not need to be self signed. \ |
| 111 |
To authenticate a user ID containing just the specified display name, \ |
| 112 |
use `--userid NAME`.")) |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
const EXAMPLES: Actions = Actions { |
| 119 |
actions: &[ |
| 120 |
Action::example().comment( |
| 121 |
"Verify that Alice ceritified a particular User ID for Bob's certificate.", |
| 122 |
).command(&[ |
| 123 |
"sq", "pki", "path", |
| 124 |
"EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 125 |
"511257EBBF077B7AEDAE5D093F68CB84CE537C9A", |
| 126 |
"--userid", "Bob <[email protected]>", |
| 127 |
]).build(), |
| 128 |
], |
| 129 |
}; |
| 130 |
test_examples!(sq_pki_path, EXAMPLES); |