Debian Codegraph @

src/commands/pki/vouch/add.rs

raw
1 use sequoia_openpgp as openpgp;
2 use openpgp::Result;
3
4 use crate::Sq;
5 use crate::cli::pki::vouch::add;
6 use crate::commands::FileOrStdout;
7 use crate::sq::TrustThreshold;
8
9 pub fn add(sq: Sq, mut c: add::Command)
10 -> Result<()>
11 {
12 let certifier =
13 sq.resolve_cert(&c.certifier, TrustThreshold::Full)?.0;
14
15 let (cert, source) = sq.resolve_cert(&c.cert, TrustThreshold::Full)?;
16 if source.is_file() {
17 // If the cert is read from a file, we default to stdout.
18 // (None means write to the cert store.)
19 if c.output.is_none() {
20 c.output = Some(FileOrStdout::new(None));
21 }
22 }
23
24 let vc = cert.with_policy(sq.policy, Some(sq.time))?;
25 let userids = c.userids.resolve(&vc)?;
26
27 let notations = c.signature_notations.parse()?;
28 let expiration =
29 sq.config.pki_vouch_expiration(&c.expiration, c.expiration_source);
30
31 crate::common::pki::certify::certify(
32 &mut std::io::stderr(),
33 &sq,
34 true, // Always recreate.
35 &certifier,
36 &cert,
37 &userids[..],
38 ! c.userids.all().unwrap_or(false), // User-supplied user IDs.
39 &[(c.amount, expiration)],
40 0,
41 &[][..], &[][..], // Domain, regex.
42 c.local,
43 c.non_revocable,
44 &notations[..],
45 c.output,
46 false)
47 }