Commit Graph

911 Commits

Author SHA1 Message Date
Neal H. Walfield
f0bfdfd1cd
Remove sq pki link retract's positional argument for specifying a user ID.
- `sq pki link retract` has a positional argument for specifying a user
    ID directly or by email address.  Remove it in favor of the named
    arguments, `--userid` and `--email`.

  - See #318.
2024-10-15 17:32:25 +02:00
Neal H. Walfield
dd75de8178
Remove sq pki link add's positional argument for specifying a user ID.
- `sq pki link add` has a positional argument for specifying a user
    ID directly or by email address.  Remove it in favor of the named
    arguments, `--userid` and `--email`.

  - See #318.
2024-10-15 17:31:49 +02:00
Neal H. Walfield
34df026d87
Change sq pki link retract to use a named argument for the certificate.
- `sq pki link retract` uses a positional argument to specify the
    certificate to retract.  Change it to be a named argument, `--cert`.

  - See #318.
2024-10-15 17:30:57 +02:00
Neal H. Walfield
bc075f9328
Change sq pki link add to use a named argument for the certificate.
- `sq pki link add` uses a positional argument to specify the
    certificate to link.  Change it to be a named argument, `--cert`.

  - See #318.
2024-10-15 17:30:22 +02:00
Justus Winter
0a55f6cdc4
Add sq cert export --local to export non-exportable sigs.
- Fixes #185.
2024-10-15 16:04:58 +02:00
Justus Winter
8fc420ddac
Show more information about downloaded certificates.
- Fixes #189.
2024-10-15 14:43:33 +02:00
Justus Winter
d2df48da93
Support indentation parameters in qprintln. 2024-10-15 14:43:33 +02:00
Justus Winter
fda522a13e
Fix hint. 2024-10-15 14:43:33 +02:00
Neal H. Walfield
a9d419973c
Check that we don't certify our own certificate.
- `sq pki certify` and `sq pki authorize` are for creating
    third-party certifications.

  - Error out if the certifier is the same as the certificate being
    certified.
2024-10-15 12:55:56 +02:00
Neal H. Walfield
2caba0758e
Refactor user ID resolution.
- Add `UserIDDesignators::resolve` to resolve user ID designators
    for a given certificate.

  - Use it from `sq pki certify` and `sq pki authorize`.
2024-10-15 12:49:52 +02:00
Neal H. Walfield
1a32d11c8f
Add a user ID designator abstraction.
- Add a new type, `UserIDDesignators`, which can be flattened into a
    clap subcommand, and exposes one or more user ID designator
    arguments (`--userid`, `--email`), and an optional `--add-userid`
    flag.

  - Change `sq pki certify` and `sq pki authorize` to use it.
2024-10-15 12:15:49 +02:00
Neal H. Walfield
f11b3f6b59
Extend sq pki authorize to constrain by domain.
- Constraining an introducer by regex is error prone.  Add an option
    to `sq pki authorize` to constrain an introducer by domain name.
2024-10-14 17:46:18 +02:00
Neal H. Walfield
d303694e9d
Move the domain to regex conversion functionality to common.
- Move the code that converts a domain to a regular expression in
    `src/commands/pki/link.rs` to `src/common/pki/certify.rs`.
2024-10-14 17:46:18 +02:00
Neal H. Walfield
712bb1991b
Don't specify value_name twice for a single argument. 2024-10-14 17:46:18 +02:00
Neal H. Walfield
22284ed9b1
Add new subcommand sq pki authorize.
- Previously `sq pki certify` could create certifications, and mark
    a certificate as a trusted introducer (when the user set `--depth`
    to be greater than zero).  Anecdotal evidence indicates that
    combining these two actions in a single command is confusing.

  - Split the latter functionality off, and put it in a new subcommand,
    `sq pki authorize`.

  - See https://gitlab.com/sequoia-pgp/sequoia-sq/-/issues/249#note_1865470753
2024-10-14 17:46:18 +02:00
Neal H. Walfield
bea0a5b732
Generalize Sq::pki_certify to certify multiple user IDs at once.
- Generalize `Sq::pki_certify` to certify multiple user IDs at once.
2024-10-14 17:46:18 +02:00
Neal H. Walfield
8ecae27594
Reorder sq pki certify's options.
- Reorder `sq pki certify`'s arguments so that they appear in a more
    logical order when reading `--help` (required arguments first,
    then grouped and approximately ordered by how often they are
    likely to be used).
2024-10-14 17:46:17 +02:00
Neal H. Walfield
3d63b8de96
Change sq pki certify to use a named argument for the certificate.
- `sq pki certify` uses a positional argument to specify the
    certificate to certify.  Change it to be a named argument, either
    `--cert`, or `--cert-file`.

  - See #318.
2024-10-14 17:46:12 +02:00
Neal H. Walfield
e40181bb57
Extend the cert designator framework to support required arguments.
- Rename the `CertDesignators`'s generic type `Options` to
    `Arguments` and add a generic type `Options`.

  - Define two options, `OneValue`, and `OptionalValue`.

  - When creating an argument group make the group required by
    default (i.e., at least one argument from the group must be given).
    If `OneValue` is set, disallow more than one value.  If
    `OptionalValue` is set, allow zero values.
2024-10-14 17:13:08 +02:00
Neal H. Walfield
b40f545a24
Change sq pki certify to use a named argument for the user ID.
- `sq pki certify` uses a positional argument to specify the user
    ID to certify.  Change it to be a named argument, either
    `--userid`, or `--email`.

  - This changes the meaning of `--email` from a flag that changes how
    `--userid` interprets its argument, to an argument.

  - This also allows multiple user IDs to be specified at once.

  - See #318.
2024-10-14 17:13:08 +02:00
Neal H. Walfield
4a3c360f41
Refactor sq pki certify, sq pki link add and sq pki link retract.
- Pull similar functionality out of the implementation of `sq pki
    certify`, `sq pki link add`, and `sq pki link retract`, and put it
    in a new module, `common::pki::certify`.

  - This slightly changes the human readable output.
2024-10-14 17:13:08 +02:00
Neal H. Walfield
56b8065b82
Add a None variant to the TrustAmount enum. 2024-10-14 17:07:57 +02:00
Neal H. Walfield
0e8ae33b22
Simplify the active_certification utility function.
- `active_certification` takes a fingerprint, and looks up the
    corresponding certificate in the certificate store.  But, all
    callers already have the certificate.  Avoid a lookup by taking a
    reference to the certificate.
2024-10-14 17:07:57 +02:00
Justus Winter
d8f8d167a6
Emit a hint if sq cert importing a key.
- Fixes #367.
2024-10-14 15:07:07 +02:00
Justus Winter
a7389f78b0
Drop the free-form command hint interface. 2024-10-14 14:45:05 +02:00
Justus Winter
72f1af22d8
Make all command hints use the structured hint framework.
- And fix all mistakes and CLI rots that crept in.  Also, align the
    hints a little.
2024-10-14 14:45:03 +02:00
Justus Winter
20ee1c77d1
On debug builds, parse the emitted hints and panic if that fails. 2024-10-14 14:44:48 +02:00
Justus Winter
718bffbe9f
Add a structured command hint framework.
- Instead of producing a free-form string, add a
    `std::process::Command`-inspired framework for command hints.

  - There are three benefits: First, we can provide robust quoting.
    Then, we can validate sq invocations using the CLI parser.
    Finally, we can nicely wrap the hints.
2024-10-14 14:44:47 +02:00
Justus Winter
1e54dc4c72
Emit hint on how to extract a particular certificate.
- Fixes #296.
2024-10-14 12:03:12 +02:00
Justus Winter
fdeb745fba
Move function. 2024-10-14 11:50:03 +02:00
Justus Winter
bc30d73f76
Always list found certificates, and reword the message.
- Also list the found certificates when writing to a file.

  - Emphasize that the results are not to be trusted by saying that
    the are related to the query.

  - See #296.
2024-10-14 11:44:03 +02:00
Justus Winter
e2fbc4b9b5
Rename sq network fetch to search, likewise hkp, WKD, and DANE.
- Rename `sq network fetch` to `sq network search` to emphasize that
    this is key discovery, and may return related or even wrong results.
    Likewise for the key server, WKD, and DANE methods.

  - See #296.
2024-10-14 10:50:11 +02:00
Justus Winter
3ff6b50fa9
Merge certificates fetched from the network earlier. 2024-10-14 10:50:11 +02:00
Justus Winter
bc5c6629ac
Move type ImportStatus. 2024-10-14 10:19:35 +02:00
Justus Winter
0a665ed98c
Unify key and cert import stats, be explicit about what is imported.
- When importing keys, also print whether the key or cert component
    was unchanged, new, or updated, and also print cert import stats:

      % sq key import test-modified.key

      Imported CDBDAC59F236D281AAE839E923B926148F77F86F
      test@example.org (UNAUTHENTICATED) from test-modified.key: key
      unchanged, cert updated
      Imported 0 new keys, updated 0 keys, 1 key unchanged, 0 errors.
      Imported 0 new certificates, updated 1 certificate,
      0 certificates unchanged, 0 errors.

  - By being more consistent in our output, and more explicit about
    what is happening and the distinction between key and cert, this
    will hopefully be less confusing.

  - Fixes #256.
2024-10-14 10:11:27 +02:00
Neal H. Walfield
1544660a97
Add a test to execute some sanity checks against the CLI.
- `clap` includes a function to sanity check the CLI.  Use it.
2024-10-11 17:10:16 +02:00
Justus Winter
72de5d1234
Make --rev-cert argument mandatory if --output has been given.
- Fixes #132.
2024-10-11 16:55:35 +02:00
Justus Winter
aaae90ce6e
Improve some integration tests to use more of the test framework. 2024-10-11 16:53:54 +02:00
Justus Winter
8f337bbd1e
Remove sq network keyserver publish --require-all.
- This should be the default, and ignoring errors should be done
    explicitly by the caller.

  - Fixes #359.
2024-10-11 16:11:58 +02:00
Justus Winter
383c5689a8
Always print the error message in addition to propagating it. 2024-10-11 16:10:24 +02:00
Justus Winter
e941c649b0
Emit a hint that the Mailvelope key server rejects some certs.
- Currently, the server rejects certificates that are not
    encryption-capable.

  - See https://github.com/mailvelope/keyserver/issues/149
2024-10-11 16:07:27 +02:00
Justus Winter
a5d40cd76e
Augment usage messages with examples.
- Fixes #319.
2024-10-10 18:13:57 +02:00
Justus Winter
9e3b020dec
Slightly indent the pointer to the global arguments. 2024-10-10 16:23:08 +02:00
Justus Winter
307a8bc806
Provide helpful guidance if there are no secret keys.
- Fixes #228.
2024-10-10 16:22:40 +02:00
Justus Winter
4737f55511
Make sq key generate --rev-cert behave like other outputs.
- Notably, this allows the revocation certificate be written to
    stdout, unless --output is also stdout, in which case we throw an
    error.

  - Fixes #219.
2024-10-10 13:58:09 +02:00
Justus Winter
2bc425e080
Move CLI definition of sq key generate to its own module. 2024-10-10 13:40:28 +02:00
Justus Winter
1a8ff4349a
Display the signers cert fingerprint when inspecting artifacts.
- Fixes #243.
2024-10-10 13:19:43 +02:00
Justus Winter
c93cd3d667
Fix formatting. 2024-10-10 12:33:19 +02:00
Justus Winter
4a635d2be2
Return the selected certificate from Sq::best_userid_for. 2024-10-10 12:32:16 +02:00
Justus Winter
1b36330763
Make Sq::best_userid_for work with use_wot=false.
- This error condition has been introduced during refactoring but
    wasn't motivated and seems superfluous.
2024-10-10 12:32:16 +02:00