Skip to content

fix(helper): isolate truststore authority aliases - #492

Open
maxlambrecht wants to merge 2 commits into
spiffe:mainfrom
maxlambrecht:fix/helper-truststore-aliases
Open

maxlambrecht wants to merge 2 commits into
spiffe:mainfrom
maxlambrecht:fix/helper-truststore-aliases

Conversation

@maxlambrecht

@maxlambrecht maxlambrecht commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What

Truststore updates now replace only aliases in the form <trust-domain>.<numeric-index>, where the suffix consists entirely of ASCII digits.

Deletions and replacement certificates are applied in memory, then flushed once per trust domain.

Why

Prefix matching treated example.org. as a match for example.org.uk.0, so updating one trust domain could delete another domain's authorities.

The old implementation also flushed after deleting entries and again after each insertion, persisting intermediate states before the replacement bundle was fully stored. Batching these changes removes those intermediate flushes. File writes still happen in place; this change does not make file replacement atomic.

How tested

  • Added a regression test that deletes example.org.0 while preserving example.org.uk.0.
  • Existing helper tests cover storing multiple authorities and removing stale indexes after a bundle shrinks.
  • Ran ./gradlew :java-spiffe-helper:test: all 46 tests passed on JDK 25.

@maxlambrecht

Copy link
Copy Markdown
Member Author

Hey @NopeCharon @cvas22! Would either of you be willing to take a look at this PR? Since you've both been contributing to the library recently, your feedback would be really valuable. Thanks!

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
@maxlambrecht
maxlambrecht force-pushed the fix/helper-truststore-aliases branch from e1b4182 to 2de2b8e Compare November 20, 2026 03:32
Stage authority updates in a separate keystore and adopt it only after
a successful write. Replace the complete bundle set with one flush,
removing authorities for absent trust domains.

Add JKS and PKCS12 regression tests for alias boundaries, failure paths,
and preservation across later flushes. Document alias ownership and
remaining file-write limitations.

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
@maxlambrecht

Copy link
Copy Markdown
Member Author

Thanks @cvas22! I addressed all three points. Updates now use a staged keystore and one write for the complete bundle set, removing absent domains. Added alias-boundary and failure-path tests for JKS and PKCS12, and documented the remaining write limitations.

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.

2 participants