Skip to content

feat(repeater): add the --pkcs11-cert, --pkcs11-module and --pkcs11-provider options - #816

Merged
aborovsky merged 3 commits into
feat/pkcs11-smart-cardfrom
feat/pkcs11-cert-option
Nov 9, 2026
Merged

aborovsky merged 3 commits into
feat/pkcs11-smart-cardfrom
feat/pkcs11-cert-option

Conversation

@aborovsky

@aborovsky aborovsky commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Configuration for PKCS#11 (smart card / token) client certificates on bright-cli repeater, for HTTPS targets. This PR only parses, validates and registers the options; the TLS integration comes in a follow-up PR.

--pkcs11-cert <json> (repeatable). Also accepted:

  • REPEATER_PKCS11_CERT: one JSON object, or a JSON array of them;
  • pkcs11Cert in .brightrc*: an object, or an array of objects.
Field Required Default
hostname yes –
module yes, unless --pkcs11-module is set --pkcs11-module
pinFile or pinEnv exactly one –
port, token, object, id (hex CKA_ID) no –
cert no "token" (or a PEM file path)
maxConcurrency no 1

--pkcs11-module <path> is the default vendor library for entries without module. --pkcs11-provider <path> overrides the OpenSSL provider plugin location.

Validation

All of it runs before the repeater starts, and each error names the entry, e.g. Option --pkcs11-cert #2 (hostname "b.example.com"): specify "module" ….

  • Missing hostname, module or PIN source, or two PIN sources.
  • A literal pin, which would land in argv, ps and the daemon service definition.
  • Unknown or misspelled fields.
  • pinEnv:
    • must be a variable name; the value is never echoed, in case someone types the PIN there;
    • must not start with REPEATER_, because yargs reads those names as options;
    • must be set.
  • module, pinFile, cert, --pkcs11-module and --pkcs11-provider must be existing files. pinFile must also be readable. All paths are resolved to absolute ones.
  • An invalid port, id or maxConcurrency.
  • --daemon rejects pinEnv, because the service doesn't inherit the shell environment. --remove-daemon skips the checks.

Also fixed

--cert entries from the config file arrive as objects, or as a single object, and used to crash in JSON.parse. Both options now accept strings, objects and arrays.

Checks

  • lint, format, build and test:unit (29 suites, 402 tests) pass. tsc reports no new errors.
  • New specs:
    • Pkcs11CertParser.spec.ts: parse and resolveFile;
    • RunRepeater.spec.ts: registration, defaults, provider, the real pinEnv, REPEATER_PKCS11_CERT arrays, config-file objects and arrays, --cert on the command line, daemon install and remove, and rejection.
  • Manual: repeater --help lists the options, and an invalid entry exits with code 1 and the entry-specific message, the same way the existing --id validation fails.
  • An automated review (semantic_reviewer) of the first revision found 12 issues; all are addressed in the second commit.

…rovider options

Smart-card client certificates need a configuration that points at the
key on a PKCS#11 token instead of a file. --pkcs11-cert takes one JSON
entry per target: hostname, module (or the --pkcs11-module default), a
PIN source (pinFile or pinEnv), and optional port, token, object, id,
cert and maxConcurrency. --pkcs11-provider overrides where the OpenSSL
provider plugin is loaded from.

Entries are validated before the repeater starts, and each error names
the entry it comes from. A literal "pin" is rejected because the
arguments end up in the process list and in the daemon's service
definition; misspelled fields are rejected instead of silently ignored.

The options are parsed and registered only; the TLS integration follows
separately. --cert now also accepts objects, which is what the config
file supplies, instead of failing in JSON.parse.
…nd daemon use

- "pinEnv" must be a variable name. The value is never echoed, so a PIN
  typed there by mistake stays out of logs. REPEATER_* names are rejected
  because yargs reads them as repeater options.
- REPEATER_PKCS11_CERT may hold a JSON array, and the config file may give
  a single object instead of an array, for --cert as well.
- Paths are resolved to absolute ones, since the daemon service runs from
  another directory. "pinEnv" is rejected when installing the daemon,
  whose service does not inherit the shell environment, and the checks
  are skipped when removing the daemon.
- --pkcs11-module and --pkcs11-provider must be existing files whether or
  not an entry uses them, and the entries are parsed once instead of in
  both validation and registration.
…oduce

The daemon service re-parses the original arguments from its own working
directory and without the installing shell's environment. Installing
therefore rejects relative PKCS#11 paths and REPEATER_PKCS11_CERT,
instead of reporting success and failing when the service starts.

"pinEnv" names starting with REPEATER are rejected, with or without an
underscore, because yargs reads all of them as repeater options.
@aborovsky
aborovsky merged commit 003cf0e into feat/pkcs11-smart-card Nov 9, 2026
20 checks passed
@aborovsky
aborovsky deleted the feat/pkcs11-cert-option branch November 9, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant