Repository navigation
refactor: resolve signing keys from signing policies - #617
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
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?
| 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) |
There was a problem hiding this comment.
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.
| // 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 |
There was a problem hiding this comment.
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.
f30907e to
b7d97e6
Compare
zeroshade
left a comment
There was a problem hiding this comment.
Re-reviewed after the rebase; still LGTM.
- The
trustedSignerconflict with #616 is resolved correctly:replayLocknow passesr.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.
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.
RegistrySigningPolicytoSigningPolicyandRegistrySigningOperationtoSigningOperation.SigningPolicy.ResolveKeyreplacesRegistry.ResolveSigningKey, andSigningOperation.ResolveKeytakes a policy.SigningOperation.ResolvePackageremains registry-only and derives signer identities from the registries it compares, so callers cannot pass in an arbitrary source identity.