Repository navigation
feat(vault): resolve every entry when no refs are given - #2114
Merged
Merged
Conversation
VaultHandler.initKeys/initSigners/initTrust now treat a null or empty ref list as "resolve every entry this vault instance exposes" instead of an error/empty result, per #1576. This lets a dynamically-assembled tls binding (e.g. a composite generator with no way to invent alias names) reference a vault without itemizing every alias. vault-filesystem implements the wildcard by enumerating the underlying keystore's entries, or restricts to a configured entries: [...] allow-list on FileSystemStoreConfig (keys/trust/signers) so two vault instances can point at the same shared keystore/truststore while each exposing a different subset for the wildcard path. Explicit alias lists are unaffected. Also fixes a latent NPE in the trust cacerts-merge path when no trust refs were given but trustcacerts merging was requested. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RyXdY3ZzQ4Hhqv4cf3RfBP
Revisits the initKeys/initSigners/initTrust wildcard design from the previous commit. Overloading null/empty on the existing List<String> parameter conflated too many concerns: the tls binding needs to know whether trust/keys/signers was actually configured (to decide the trustcacerts default), and the only way to signal "nothing resolved" on the KeyManagerFactory/TrustManagerFactory return side is null, so doubling up null's meaning on the input side was lossy. VaultHandler gains initKeys(), initSigners(), and initTrust(KeyStore) as new abstract methods (all four implementations are ours, so no default-method back-compat concern). The existing List-based methods revert to their original, pre-wildcard contract unchanged: null means "not configured", exactly as before this feature existed. FileSystemVaultHandler/TestVaultHandler implement the new methods by resolving to every entry the vault instance is configured to expose (entries allow-list, or full store enumeration for vault-filesystem; the single configured alias for the test vault) and delegating into the unchanged List-based methods. TlsBindingConfig calls the new wildcard methods only when none of keys/trust/signers is configured at all - a previously inert config shape - preserving existing behavior everywhere else. Keys wildcard tries initKeys() first, falling back to initSigners(), matching the existing keys-over-signers precedence for the explicit-list path. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RyXdY3ZzQ4Hhqv4cf3RfBP
KeyManagerFactory.getInstance("PKIX") returns an X509ExtendedKeyManager
that reports internally-generated composite aliases (e.g. "1.0.alias1"),
not the literal keystore alias, so getPrivateKey(rawAlias) always
returned null for the new wildcard assertions. Resolve the private key
by matching the certificate's CN against the requested alias instead.
Resolving a private key by literal alias assumes the KeyManagerFactory preserves the keystore alias string, which is an implementation detail of the algorithm (PKIX renumbers aliases internally; SunX509 does not). Assert on X509KeyManager.getServerAliases(keyType, issuers).length instead, mirroring the existing trust-side wildcard tests that count getAcceptedIssuers() rather than matching by name. This is guaranteed by the KeyManager contract for any provider and needs no knowledge of how a given algorithm derives its aliases.
Each wildcard test now reads linearly without jumping to a shared private helper.
… too entries was only consulted by the no-arg wildcard methods (initKeys()/initTrust(KeyStore)/initSigners()). A caller passing an explicit alias list bypassed it entirely, so a vault instance scoped to a subset of a shared keystore file would still resolve any alias physically present in that file. Move the check into the shared key()/certificate() alias resolvers so entries is a hard boundary regardless of how an alias is requested.
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.
Description
VaultHandlergains three new methods —initKeys(),initSigners(), andinitTrust(KeyStore)— that resolve to every entry a vault instance is configured to expose, instead of requiring a caller to itemize aliases. This is for callers that have no way to invent or discover alias names ahead of time, such as atlsbinding assembled dynamically by a composite generator.The existing
initKeys(List),initSigners(List), andinitTrust(List, KeyStore)methods are unchanged from their original contract —nullstill just means "not configured." The wildcard is only reachable through the new dedicated methods, never by overloading a sentinel value on the existing parameter (the return type can only signal "nothing here" vianull, so doubling that meaning onto the input side would have been lossy — see PR discussion for the earlier approach this replaces).vault-filesystemimplements the new methods by enumerating the underlying keystore, or by an optionalentries: [...]allow-list onFileSystemStoreConfig(keys/trust/signers), so two vault instances can share one keystore/truststore file while each exposing a different subset. Once configured,entriesis a hard boundary enforced the same way regardless of whether an alias is resolved via the wildcard or requested explicitly — a caller can't bypass the allow-list by naming an alias directly that isn't inentries.TestVaultHandler(engine test implementation) implements the new methods by delegating to the existing list-based methods with its single configured key/signer alias and full trust list.TlsBindingConfigcalls the new wildcard methods only when none ofkeys/trust/signersis configured on the binding at all — a previously inert config shape — falling back frominitKeys()toinitSigners()for identity material, matching the existing keys-over-signers precedence. Every other configuration shape is byte-for-byte unchanged.Also fixes a latent NPE in
FileSystemVaultHandler's trust/cacerts-merge path that could be hit whenever no trust refs were configured but cacerts merging was requested.Fixes #1576
Generated by Claude Code