-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Problem
I'm working on a crate registry where I'm able to advertise a set of crate versions that may be generated, but the crates themselves are only lazily generated when they're requested — so I don't have a checksum to publish initially. After the generation occurs, I can publish the checksum, and it is not expected to change.
Currently, cargo
will not function if the checksum is not populated — it'll attempt to compare the empty string to the checksum of the downloaded crate, which will fail and stop the installation of the crate. I'd like to not need to pre-generate all possible versions just to populate the version checksums in the index.
Proposed Solution
I'd like the ability to specify, at a registry level, to disable checksum validation altogether. I'd imagine this looking is something like:
# in .cargo/config.toml
[registries]
my-registry = { verify-checksums = "no" }
Where the default value for verify-checksums
is "yes"
.
Alternative solution
An alternative would be the ability to specify only validating a downloaded crate's checksum when a value is set in the registry (somewhat similar to how the Go Module Proxy works, where the initial module download populates the checksum value). I'd imagine this looking is something like:
# in .cargo/config.toml
[registries]
my-registry = { verify-checksums = "if-non-empty" }
Notes
I'm aware that this can introduce security risks (you should only enable this if you trust the registry that you're using), but I've been able to implement a similar lazy generation scheme across a variety of package ecosystems — cargo is the only one (so far) that has strictly required package version checksums in this way.
The alternative proposal is more secure in the sense that the checksum can at least be compared to a stable value once it's known, but still requires trust in the registry.
I wasn't able to find a prior request quite like this, but somewhat related is #10071. It also may allow for solutions to issues like #10939, where a local registry is required to serve a non-existent checksum.