Skip to content

feat: configure signing keys for third-party registries - #595

Merged
zeroshade merged 47 commits into
columnar-tech:mainfrom
eitsupi:feat/third-party-signing-keys
Nov 25, 2026
Merged

zeroshade merged 47 commits into
columnar-tech:mainfrom
eitsupi:feat/third-party-signing-keys

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #576. Custom registries (#360) can name the key their packages are signed with, so drivers from them no longer need --no-verify. This also turns on the signer check of #601 for these keys. Closes #613.

[signing_keys.acme]
type = "openpgp"
public_key_file = "keys/acme.asc"  # or public_key = "-----BEGIN PGP PUBLIC KEY BLOCK-----..."

[[registries]]
url = "https://drivers.acme.example.com"
signing_key = "acme"  # omitted: built-in Columnar key; false: unsigned registry
  • Config: in the user config.toml and in dbc.toml. A signing_key name is resolved only in the file that declares the registry, so adding a key to the user config never changes what a project trusts. A project cannot declare a registry from the user config or a default registry (compared without query, user information or default port) with a different signing policy; that is an error. An omitted signing_key always means the built-in Columnar key. columnar is reserved. Registry URLs in these files reject empty interior path segments, . or .. segments even when escaped, and escaped slashes, so that another spelling of a trusted registry's path cannot get past this check. Registry identities, including lockfile sources, omit default ports and normalize path escapes by decoding unreserved characters and uppercasing the remaining hex digits, preserving the distinction between escaped and literal reserved characters.
  • Keys: exactly one public certificate, armored (or binary in a file). Private keys, several keys or armor blocks, unknown packets and trailing data are rejected instead of skipped. A relative public_key_file is relative to the file that defines it; in dbc.toml it must stay inside the project directory (no absolute or UNC paths or .. that leaves it, read through os.Root). The file is read only when its key is needed, also for the signer check, and the certificate read is reused for the rest of the operation; a failure is an error, never a fallback to another key.
  • Signer check: when several registries list a driver, or an index is missing, their signers must match (feat!: fall back only between registries with the same signer #601). Keys match only when their certificates are identical, and every unsigned registry is a signer of its own, so a missing index of an unsigned registry, or of one with a key the others do not share, stops new resolution of drivers without a source. The signer check, the verification and the lock pin of one operation use the same certificate, even if a public_key_file changes meanwhile.
  • Lockfile: the selected key's fingerprint is pinned as in feat(lock)!: pin the signing key fingerprint in lockfile v2 #576, or type = 'none' for signing_key = false. Replay requires the registry's current configuration to select the same signer, also with --no-verify, so a lock entry can neither switch keys nor turn verification off on its own. Each unsigned registry counts as a separate signer, so a driver locked from one is not resolved again from another unsigned registry, even with a changed source.
  • Install: dbc install and Client.Install select the key from the registry of the chosen package before downloading it, so a driver that a later registry with the same key serves (feat: handle multiple registries serving the same driver name #584) is verified with that registry's key. --no-verify / AllowUnsigned skip the signature check, but not the signer check of an implicit selection; local archives keep using the Columnar key. The install and sync JSON report signature_verified, and verify.start / verify.complete are only emitted when a signature is checked.
  • API: Registry.Signing (RegistrySigningPolicy, zero value = Columnar key) with SignWith / Unsigned, plus NewSigningKey and Registry.ResolveSigningKey. RegistrySigningOperation keeps the keys of one operation; its ResolvePackage replaces the unreleased function of the same name (feat: handle multiple registries serving the same driver name #584, feat!: fall back only between registries with the same signer #601). The unreleased LoadProjectRegistries / WithProjectRegistries become LoadProjectConfig / WithProjectConfig, so key definitions and their file path travel with the registries. Bindings take signingKey on explicit registries (registry.<n>.signing_key in the C API).

The policy only covers detached OpenPGP signatures of registry packages; another source such as Packslip would get its own policy and lock signer type.

Add [signing_keys.<name>] definitions and a signing_key setting on
[[registries]] to the user config and to dbc.toml. A registry that omits
signing_key keeps the built-in Columnar key, a name selects a key defined
in the same file, and false declares an unsigned registry. Names are never
looked up in another file, and "columnar" is reserved.

Keys are parsed strictly: the input must be exactly one public
certificate, and private key material, several primary keys, several
armored blocks, unknown packets and trailing data are rejected instead of
skipped.

Registry carries the resulting SigningPolicy, and the project registry
configuration is now passed as a ProjectConfig so that the definitions and
the file they come from travel with the registries.
Reject armored keys with lines between the checksum and the END line,
which the armor decoder stops reading at, and split binary keys into
packets by their declared lengths so that a truncated packet or one with
unparsed data is an error instead of the end of the input.

Compare signing policies by the whole certificate, so that dbc add notices
a new subkey or revocation of the same primary key, and check the
registry configuration of dbc.toml whenever it is decoded, so that
dbc remove does not write back an invalid one.

Rename the policy type to RegistrySigningPolicy, since it only covers the
detached signatures of registry packages.
A four-octet body length above MaxInt32 became negative on 32-bit
platforms, passed the bounds check and could make slicing panic. Keep the
length in a uint64 until it is known to fit in the input.
A [signing_keys] definition can name a file holding the public key,
armored or binary, instead of embedding it. A relative path is resolved
against the directory of the configuration file that defines it, without
following symbolic links or expanding "~" or environment variables.

The file is read the first time a registry that names the definition
needs its key, so a missing file only fails the operations that use it,
and the key is kept for the life of the client. Only a regular file of at
most 1 MiB is read, and any failure is an error rather than a fallback to
another key. The browser build rejects key files.
dbc sync and dbc lock now verify the packages of a driver with the key
that its registry's configuration selects, record that key in the lock
file, and replay a lock entry only when the configuration of its bound
registry still selects the same key. A driver from a registry declared
unsigned is locked with signer type "none" and no fingerprint, and is
installed without a signature check; a lock entry cannot turn
verification off or switch keys on its own. A key that cannot be loaded
fails before any index is fetched or archive downloaded.

Explicit registries passed to the bindings take an optional signingKey
(an armored public key, or false), which the C API exposes as
registry.<n>.signing_key.
Read a public_key_file again on every use instead of caching it for the
life of the client, so that a long-lived client of the bindings sees a key
that is added, fixed or updated. The sync planner instead keeps the signer
of each registry for one plan, so all drivers of one sync or lock are
verified with the same certificate.

Check the optional armor checksum, which the armor decoder ignores, and
keep the content of an invalid signingKey value out of error messages.
Fetch the index of a bound registry with its configuration.
Document signing_key and [signing_keys] for registries, how a key is read
from public_key_file, how dbc.lock pins the selected key, and the Go and
binding APIs for explicit registries. Also correct the planner comment:
reusing one signer per plan does not make dbc lock verify archives it
does not download.
Registry takes an optional SigningKey, an armored public key or Unsigned,
passed to the C API as registry.<n>.signing_key.
A path such as \keys\a.asc or C:keys\a.asc is not absolute on Windows
and depended on the current drive or directory; it was joined to the
directory of the configuration file instead. Reject it, and use real
absolute paths in the test that failed on Windows.
dbc install and Client.Install now select the signing key from the
registry of the chosen package before downloading it, so a driver that a
later registry serves is verified with that registry's key. A key that
cannot be loaded fails before the download, an unsigned registry skips
the signature check, and local archives keep using the Columnar key.
@eitsupi
eitsupi force-pushed the feat/third-party-signing-keys branch from 4a85a18 to c9f3529 Compare November 19, 2026 23:53
The browser Wasm build rejects public_key_file when the configuration is
loaded, so the test that a missing key file fails before the download
moves to a file that the browser build excludes.
The example writes Columnar's public key inline for the default public
registry, so it can be tried as is. Details that matter only for edge
cases are left out of the user-facing page.
@eitsupi
eitsupi marked this pull request as ready for review November 20, 2026 00:25
@eitsupi
eitsupi requested review from amoeba and zeroshade November 20, 2026 00:25
Each case locks a driver, installs it with dbc sync, reuses the install
on a second sync, and rejects the lock once the registry is configured
with another signer, also with --no-verify.

@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.

Security review of how the new keys are trusted. The key parser, the lockfile pinning and the fail-closed paths look solid; these comments are about what a configured key is trusted for.

Comment thread registry_config.go Resolved
Comment thread registry_config.go Resolved
Comment thread signing_key_file.go Resolved
Comment thread cmd/dbc/install.go Resolved
Comment thread docs/concepts/driver_registry.md Resolved
Comment thread registry_config.go Resolved
@eitsupi
eitsupi marked this pull request as draft November 21, 2026 00:53
@eitsupi
eitsupi marked this pull request as draft November 23, 2026 22:29
Resolve the conflicts with the rename of replace_defaults to
exclude_builtin_registries: ProjectConfig.ExcludeBuiltinRegistries is a
bool, and the user and project settings are combined with a logical OR.
A project therefore can no longer bring back the built-in registries,
so the defaults are compared in checkProjectRedeclarations exactly when
the user config does not exclude them. Repeated registry names in one
file are rejected while the entries are converted to registries.
eitsupi added a commit that referenced this pull request Nov 25, 2026
Addresses the review of #595: with #584, a registry that serves a driver
name also serves it for every driver list that does not pin it, so
adding a registry with its own key adds a code signer for every name it
lists. This keeps the #584 fallback, which is what lets a driver move
between the built-in registries, but only between registries with the
same signer, and makes the choice fail when it cannot be checked.

- **Same signer:** when several registries list a driver name, whatever
their versions and platforms, they must all verify their packages with
the same signer. Otherwise `ResolvePackage` returns a
`SignerConflictError` that names the registries and their signers,
before any package is selected or downloaded, and the CLI suggests a
`source` in `dbc.toml` (#599) or `--registry`. Registry priority stays
project → user → built-in.
- **Missing index:** a registry whose index cannot be fetched or read
might list the driver too. Its signer is known from its configuration,
so `ResolvePackage` returns `ErrIncompleteIndex` only if that signer
differs from the signer of the registries that list the driver (or, if
none does, from another failed registry's signer), or if it cannot
identify the failed registry or its signer. A failed registry with the
same signer is skipped, as before this PR. This applies to new
resolution in `dbc add`, `dbc install`, `dbc lock`, `dbc sync`,
`Client.Install` and `Resolve` in the bindings. Replaying a lock entry
that still satisfies the driver list, drivers with a `source` and `dbc
install --registry` only need the registries they use.
- **API:** `ResolvePackage` (unreleased, from #584) takes the error that
`Search` returned with the drivers. `Search` reports each failed
registry as a `RegistryIndexError` with the registry's configuration;
its message leaves out the user information and query of the registry
URL, also where the HTTP error repeats the request URL.
- **Bindings' `Resolve`:** invalid registry metadata during package
selection, such as a malformed archive hash or a missing version, now
returns an error. If a listed driver has no eligible version, `Resolve`
still returns its versions without `latest`. Previously both cases
returned the same kind of result, even though `Install` already rejected
the same invalid metadata on the host platform.
- **Relation to #595:** there is no per-registry key setting yet, so
every registry is verified with the built-in Columnar key: no conflict
can occur and no failed index fails the signer check until #595 lands.
#595 will derive the identity from each registry's signing policy (the
digest of the configured certificate for a key, and an identity of its
own for each unsigned registry), marked with TODO comments. Once #595
lands, a failed registry with a different signer can block resolution of
drivers without a `source`. This should not be released before #595.
…gning-keys

# Conflicts:
#	cmd/dbc/driver_list.go
#	cmd/dbc/sync.go
#	cmd/dbc/sync_plan.go
#	docs/reference/cli.md
Add RegistrySigningOperation, which resolves the signing keys of
registries for one operation, so that the signer check of
ResolvePackage, package verification and the lock pin use the same
certificate even when a public_key_file changes meanwhile. Keys are
compared by the digest of the whole certificate, and every unsigned
registry is a signer of its own. Signers are only compared when several
registries list a driver or an index is missing.
Add, install, lock and sync stop on registries with different signers
and on a missing index of a registry with another signer, with the hint
of each command, while a chosen registry still resolves and verifies
with its key. Registries with the same certificate fall back to one
another.
The lock file's source identity and dbc add's check for a changed
registry kept an explicit default port, while merging and the signing
trust check dropped it. Share one normalization of the scheme and host
in internal/registryurl.
Requests clean such a path, so another spelling of a trusted
registry's URL could get past the check that a project cannot change
how that registry is verified.
The lock file pins no key for an unsigned registry, so resolving such a
driver again compared equal signers even when it moved to another
unsigned registry, which is another signer.
An escaped unreserved character, such as %64 for d, and the case of hex
digits do not change the path a request reaches, so they no longer make
a registry another one when merging, checking that a project cannot
change how a trusted registry is verified, matching a source or writing
the lock file. Reserved characters keep their spelling.
@eitsupi
eitsupi requested a review from zeroshade November 25, 2026 01:16
@eitsupi
eitsupi marked this pull request as ready for review November 25, 2026 01:16
@eitsupi

eitsupi commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

I merged main, including #598, #599, and #601, and resolved the conflict around exclude_builtin_registries.
For drivers listed by registries with different signers, dbc now requires an explicit registry choice.

The signer check uses the configured signing policies and reuses the same certificate for verification and lock pinning.
I added the CLI tests from #613, kept unsigned lock entries tied to their original registry, and made registry URL comparisons consistent so alternate spellings cannot bypass the signing policy check.

This grew larger than I expected.
If it would make review easier, I can split it into stacked PRs.

@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 at 3c945e4. Thanks, both items from my last pass are addressed:

  1. The merge onto exclude_builtin_registries is resolved correctly. Defaults are protected unless the user config excludes them, and a project's exclude_builtin_registries does not lift the redeclaration check.
  2. #601's signer placeholder is now backed by real identities: a digest of the whole certificate for keys, and one signer per unsigned registry. RegistrySigningOperation keeps the signer check, the verification and the lock pin on the same certificate within one operation.

The registry URL normalization (default port, RFC 3986 escapes, rejecting dot, empty and escaped-slash segments) closes the alternate-spelling route around the redeclaration check, and unsigned lock entries staying on their registry is a good addition. go vet ./... and go test ./... pass, and the browser build vets cleanly.

Non-blocking: since every unsigned registry is its own signer, an unreachable unsigned registry stops new resolution of drivers without a source. That is fail-closed and documented, and the error points to source/--registry, so it's fine as is. No need to split the PR.

@zeroshade
zeroshade merged commit a6bf214 into columnar-tech:main Nov 25, 2026
21 checks passed
@eitsupi
eitsupi deleted the feat/third-party-signing-keys branch November 30, 2026 14:43
eitsupi added a commit that referenced this pull request Dec 1, 2026
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 added a commit that referenced this pull request Dec 2, 2026
dbc used registry priority for overrides (#360), and #584 kept that
order when choosing the first registry with a matching version. This
gave order precedence over version, much as uv's default `first-index`
does to limit dependency confusion. The review of per-registry signing
keys (#595) showed that registry order could also determine the signer,
so #601 made cross-signer name collisions an error during implicit
resolution. Within that signer boundary, dbc now picks the highest
eligible version across registries, as pip does across indexes, so
drivers keep getting updates after moving to another registry.

- **Selection.** A candidate must satisfy the version requirements and
have builds for every required target in one record. Registry order
breaks ties at the highest SemVer precedence. In the winning registry, a
second eligible record of the same precedence or any duplicate of the
winning full version is an error. Exact requests include build metadata
and reject duplicate exact records even when none covers all required
targets. Errors in a selected artifact stop resolution.
- **CLI.** New resolutions can select a newer version from a
lower-priority registry. To take a driver from a specific registry, set
its `source`. Compatible lock entries still replay from their recorded
source. Successful CLI selections warn on stderr when a same-signer
index was skipped. Registry version constraints now reject build
metadata.
- **v1 lock files.** If the recorded version is no longer listed,
migration stops with or without `platforms`. A recorded version that
lacks a build for a declared platform is still resolved again.
- **Go API.** `Client.FetchIndex`, `Client.FetchRegistryIndex`, and
`SelectRegistry` replace `SigningOperation.ResolvePackage`. Requests
take a constraint or an exact version. The project planner decides
whether to keep a locked version. `Index` aliases an internal type so
public callers get complete snapshots from the client and cannot pass
filtered search results; tests outside the module can serve an index
through `NewClient` with `WithRegistries` and `WithHTTPClient`.
- **Bindings.** `Resolve` reports the highest eligible stable version as
`latest` and lists versions for the requested platform across reachable
same-signer registries, including prereleases. Go and npm-wasm expose
skipped indexes in `warning`. C and Rust warning support follows in
#633.

`Client.FetchRegistryIndex` requires exactly one configured endpoint
match before fetching. This prevents it from picking a signing policy by
list order when `WithRegistries` lists the same endpoint under different
policies.

The released `Driver` methods remain single-driver lookups. #634 aligns
`GetPackage` with exact version matching and deprecates
`GetWithConstraint`.
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.

Test registry signer conflicts end to end in the CLI

2 participants