Repository navigation
feat(repeater): add the --pkcs11-cert, --pkcs11-module and --pkcs11-provider options - #816
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;pkcs11Certin.brightrc*: an object, or an array of objects.hostnamemodule--pkcs11-moduleis set--pkcs11-modulepinFileorpinEnvport,token,object,id(hexCKA_ID)cert"token"(or a PEM file path)maxConcurrency1--pkcs11-module <path>is the default vendor library for entries withoutmodule.--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" ….pin, which would land in argv,psand the daemon service definition.pinEnv:REPEATER_, because yargs reads those names as options;module,pinFile,cert,--pkcs11-moduleand--pkcs11-providermust be existing files.pinFilemust also be readable. All paths are resolved to absolute ones.port,idormaxConcurrency.--daemonrejectspinEnv, because the service doesn't inherit the shell environment.--remove-daemonskips the checks.Also fixed
--certentries from the config file arrive as objects, or as a single object, and used to crash inJSON.parse. Both options now accept strings, objects and arrays.Checks
lint,format,buildandtest:unit(29 suites, 402 tests) pass.tscreports no new errors.Pkcs11CertParser.spec.ts:parseandresolveFile;RunRepeater.spec.ts: registration, defaults, provider, the realpinEnv,REPEATER_PKCS11_CERTarrays, config-file objects and arrays,--certon the command line, daemon install and remove, and rejection.repeater --helplists the options, and an invalid entry exits with code 1 and the entry-specific message, the same way the existing--idvalidation fails.semantic_reviewer) of the first revision found 12 issues; all are addressed in the second commit.