Skip to content

refactor: resolve signing keys from signing policies - #617

Merged
eitsupi merged 3 commits into
mainfrom
refactor/signing-policy
Dec 1, 2026
Merged

eitsupi merged 3 commits into
mainfrom
refactor/signing-policy

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #595. Generalizes the Go signing API ahead of its 0.4.0 release so the upcoming HTTP URL template source can share key resolution, signature verification, and signer pinning with registries. Existing registry behavior is unchanged.

  • Go API: Renames RegistrySigningPolicy to SigningPolicy and RegistrySigningOperation to SigningOperation. SigningPolicy.ResolveKey replaces Registry.ResolveSigningKey, and SigningOperation.ResolveKey takes a policy.
  • Key caching: Each operation still reuses the first key successfully read from disk for each signing key definition.
  • Registry selection: SigningOperation.ResolvePackage remains registry-only and derives signer identities from the registries it compares, so callers cannot pass in an arbitrary source identity.

@eitsupi eitsupi changed the title refactor/signing policy refactor: resolve signing keys from signing policies Nov 25, 2026
@eitsupi
eitsupi added this pull request to stack #619 November 25, 2026 23:01
@eitsupi
eitsupi marked this pull request as ready for review November 26, 2026 00:53
@eitsupi
eitsupi requested review from amoeba and zeroshade November 26, 2026 00:54
@eitsupi
eitsupi removed this pull request from stack #619 November 26, 2026 05:44
@eitsupi
eitsupi added this pull request to stack #624 November 26, 2026 05:45

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Since none of the old names shipped in v0.3.1, the rename doesn't need deprecation aliases, and behavior is unchanged: registrySigner's unsigned flag is the same as before (a nil registry still resolves to the Columnar key), and keys from files are still cached per definition. A few small notes inline, none blocking.

Comment thread cmd/dbc/sync_plan.go
// never falls back to another key or registry.
func (p *syncPlanner) trustedSigner(name string, sig lockedSigner, bound boundRegistry) (packageSigner, error) {
signer, err := p.signerFor(name, bound)
func (p *syncPlanner) trustedSigner(name string, sig lockedSigner, policy dbc.SigningPolicy) (packageSigner, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Heads-up: this signature change conflicts with #616, which moves the trustedSigner(name, d.Signer, bound) call into replayLock. Whichever PR lands second will need p.trustedSigner(name, d.Signer, r.bound.Registry.Signing) there.

Comment thread cmd/dbc/install.go
// configuration says, with the keys of signing; a driver without a registry
// uses the Columnar key.
func registrySigner(signing *dbc.RegistrySigningOperation, registry *dbc.Registry) (packageSigner, error) {
func registrySigner(signing *dbc.SigningOperation, registry *dbc.Registry) (packageSigner, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: the nil-registry → Columnar fallback now lives both here and in the unexported dbc.(*SigningOperation).registryKey. Could one copy go, e.g. by exporting a registry helper or having callers pass SigningPolicy{} themselves?

Comment thread cmd/dbc/sync_plan.go
func (p *syncPlanner) signerFor(name string, policy dbc.SigningPolicy) (packageSigner, error) {
signer, err := policySigner(p.signingOperation(), policy)
if err != nil {
return packageSigner{}, fmt.Errorf("driver %s: could not load the signing key of its registry: %w", name, err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: the doc comment now talks about the policy of its source in general, but this message still says "of its registry". Fine to leave until HTTP sources go through this path.

Comment thread signing_operation.go Outdated
// from a public_key_file that changes meanwhile. A key file is read only
// when a key is needed, and the key read from it is reused for the rest of
// the operation; a failed read is not remembered and is returned to the
// caller as an error. The next operation reads the file again. The zero value is ready to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this line is longer than the rest of the paragraph; could you re-wrap it?

RegistrySigningPolicy and RegistrySigningOperation become SigningPolicy and
SigningOperation, so that sources other than registries can share the key
resolution, verification and lock pin with them. Keys are resolved from a
policy: SigningPolicy.ResolveKey replaces Registry.ResolveSigningKey, and
SigningOperation.ResolveKey takes a policy instead of a registry, reading
a key file once per operation as before. ResolvePackage, which compares
the signers of registries, stays registry-only.
…tries

Also pin the public contract of SigningOperation.ResolveKey: the zero
policy is the Columnar key, only Unsigned resolves to no key, and a policy
without a key is an error.
@eitsupi

eitsupi commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

I rewrapped the comment in 80aef6c and resolved the trustedSigner conflict while rebasing onto main.
The source wording is updated in #621 (c56a274).

I kept the small nil-registry branches for now.
Both pass the default policy to the same key resolver.

@eitsupi
eitsupi requested a review from zeroshade November 30, 2026 14:31

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed after the rebase; still LGTM.

  • The trustedSigner conflict with #616 is resolved correctly: replayLock now passes r.bound.Registry.Signing.
  • The rewrap in 80aef6c looks good.
  • Fine to handle the "of its registry" wording in #621.
  • Keeping the small nil-registry branches is fine now that both pass SigningPolicy{} to the same resolver, so the fallback can't diverge.

@eitsupi
eitsupi merged commit ccce26a into main Dec 1, 2026
31 checks passed
@eitsupi
eitsupi deleted the refactor/signing-policy branch December 1, 2026 00:30

This branch was previously deployed

1 inactive deployment
snapshot — 80aef6c1 Deployed Nov 30, 2026 by eitsupi via snapshot #1408
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