Skip to content

fix: error explicitly when file signer flags are set without a key path - #806

Merged
jkjell merged 1 commit into
in-toto:mainfrom
pujitha24:auto/issue-573
Aug 15, 2026
Merged

jkjell merged 1 commit into
in-toto:mainfrom
pujitha24:auto/issue-573

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

When --signer-file-cert-path (or --signer-file-intermediate-paths / --signer-file-key-passphrase*) is set without --signer-file-key-path, the file signer provider still gets activated (any --signer-file-* flag turns it on) and its build silently fails while logging an unclear error. If another signer provider (e.g. --signer-kms-ref) also succeeds, loadSigners was returning success anyway, since it only fails when zero signers loaded. The command exits 0 with the certificate quietly dropped instead of surfacing a clear, actionable error, exactly as reported and confirmed by a maintainer on the issue.

This PR adds an explicit check in loadSigners (cmd/keyloader.go): if the file signer provider is selected with a cert/intermediate/passphrase flag but no key path, it now returns a hard, immediate error instead of silently continuing.

Which issue(s) this PR fixes (optional)

Fixes #

Acceptance Criteria Met

  • Docs changes if needed
  • Testing changes if needed
  • All workflow checks passing (automatically enforced)
  • All review conversations resolved (automatically enforced)
  • DCO Sign-off

Special notes for your reviewer:

This intentionally does not add BYOK certificate-embedding support for KMS signers (explicitly out of scope per the issue thread) — it only makes the existing incompatible-flag combination fail loudly instead of silently, per the maintainer's stated direction on the issue.

Fixes #573

Copilot AI lite review requested due to automatic review settings August 4, 2026 23:20
@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for witness-dev ready!

Name Link
🔨 Latest commit b7a3290
🔍 Latest deploy log https://app.netlify.com/projects/witness-dev/deploys/6a73930aee27b100084cabda
😎 Deploy Preview https://deploy-preview-806--witness-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents a silent “partial success” case when the file signer provider is implicitly enabled via --signer-file-* flags but lacks --signer-file-key-path. Instead of allowing other signer providers (e.g., KMS) to succeed while the file-based certificate is dropped, loadSigners now fails fast with a clear, actionable error.

Changes:

  • Add an explicit validation in loadSigners to hard-error when file-signer cert/intermediate/passphrase flags are set without a file key path.
  • Add a regression test covering the clearer failure mode/error message when --signer-file-cert-path is provided without --signer-file-key-path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/keyloader.go Adds a pre-signer-creation validation to reject incompatible file-signer flag combinations with a clear error.
cmd/root_test.go Adds a test ensuring the missing --signer-file-key-path case errors and mentions the required flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Motivation:
Setting --signer-file-cert-path (or --signer-file-intermediate-paths /
--signer-file-key-passphrase*) without --signer-file-key-path still
activates the file signer provider, since any --signer-file-* flag
turns it on. The file signer then fails to build with a confusing
"failed to open key file: open : no such file or directory" error.
Because loadSigners only errors when zero signers load, that failure
was silently swallowed whenever another configured signer (e.g.
--signer-kms-ref) succeeded: the command exited 0 with the certificate
quietly dropped. A maintainer confirmed this diagnosis on the issue
and asked that Witness explicitly inform users when incompatible flags
like --signer-file-cert-path and --signer-kms-ref are combined, rather
than embedding BYOK certificates for KMS signers (explicitly not
planned).

Approach:
In loadSigners (cmd/keyloader.go), before building the file signer,
check whether it was selected with a cert/intermediate/passphrase flag
but no key path. If so, return a hard, immediate error instead of
letting the provider fail internally and continuing past it. The
check fires as soon as the file provider is processed in the loop and
returns unconditionally, so it does not depend on the iteration order
of the provider set or on whether any other signer would have
succeeded.

Validation:
- go build ./...
- make test (this repo's documented test command; all packages pass)
- Added cmd/root_test.go:Test_loadSignersCertificateWithoutKey, which
  exercises loadSigners with only the file provider configured (cert
  path set, key path empty) and asserts a clear
  "signer-file-key-path" error is returned instead of the signers
  being silently dropped.
- Manually reproduced via the CLI: `witness run --signer-kms-ref=...
  --signer-file-cert-path <path> ...` now fails fast with a single
  actionable error instead of the previous two confusing log lines.
  This manual run used a syntactically invalid KMS ARN, since no live
  AWS credentials are available in this environment, so it did not
  exercise the original report's exit-code-0 path directly (that
  requires a KMS ref that successfully authenticates against a real
  endpoint). The fix removes the continue-on-failure behavior for this
  case unconditionally (a hard error is returned before any signer is
  appended), which by construction prevents the silent-exit-0 outcome
  regardless of whether a co-configured signer would have succeeded;
  this is confirmed by code inspection and by the new unit test above,
  not by a live-AWS repro.

Report: in-toto#573
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 5, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

cmd/root_test.go:112

  • The doc comment says this test reproduces the original issue where the invalid file-signer flags were "silently swallowed when another signer provider succeeds", but the test only configures the file provider (so it doesn’t exercise the multi-provider swallow/exit-0 scenario). Either adjust the comment to match what’s actually being tested, or extend the test to include a second provider that succeeds.
// Test_loadSignersCertificateWithoutKey reproduces
// https://github.com/in-toto/witness/issues/573: passing --signer-file-cert-path
// without --signer-file-key-path (e.g. because the certificate was meant for a
// KMS-based signer) must fail loudly with an actionable error instead of being
// silently swallowed when another signer provider succeeds.

@pujitha24

Copy link
Copy Markdown
Contributor Author

This has been green and rebased for a while now — happy to make any changes if something would help move review along.

@jkjell
jkjell merged commit 3041b83 into in-toto:main Aug 15, 2026
18 checks passed
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.

[Bug]: Unable to use AWS KMS BYOK (Bring your own key) functionality to generate attestations

3 participants