Debian Codegraph @

src/commands/pki/vouch/authorize.rs

raw
1 use sequoia_openpgp as openpgp;
2 use openpgp::Result;
3
4 use crate::Sq;
5 use crate::cli::pki::vouch::authorize;
6 use crate::commands::FileOrStdout;
7 use crate::sq::TrustThreshold;
8
9 pub fn authorize(sq: Sq, mut c: authorize::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
32 crate::common::pki::certify::certify(
33 &mut std::io::stderr(),
34 &sq,
35 true, // Always recreate.
36 &certifier,
37 &cert,
38 &userids[..],
39 ! c.userids.all().unwrap_or(false), // User-supplied user IDs.
40 &[(c.amount, expiration)],
41 c.depth,
42 &c.domain[..],
43 &c.regex[..],
44 c.local,
45 c.non_revocable,
46 &notations[..],
47 c.output,
48 false)
49 }