feat(registry,cli): RFC 7232 conditional requests; require trusted verify keys
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s

This commit is contained in:
faumaray committed 2026-12-04 09:12:10 +03:00
1 parent 27d909fdad
commit ea6ac852e7
9 files changed
+138 -6

No files matched your search

+26 -1
View File
@@ -45,6 +45,7 @@
#include <algorithm>
#include <array>
#include <cctype>
#include <charconv>
#include <chrono>
#include <cstdint>
@@ -1276,6 +1277,8 @@ struct VerifyCmdOptions {
std::optional<std::string> file_arg;
std::optional<std::string> signature_arg;
std::optional<std::string> public_key_arg;
std::vector<std::string> trusted_public_keys;
std::vector<std::string> trusted_key_files;
};
int execute_verify_command(const VerifyCmdOptions &opts) {
@@ -1285,6 +1288,23 @@ int execute_verify_command(const VerifyCmdOptions &opts) {
"required\n";
return 2;
}
auto trusted = combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files,
std::filesystem::current_path());
if (!trusted) {
std::cerr << "vbs verify: " << trusted.error().message() << '\n';
return 1;
}
if (!trusted->empty()) {
std::string supplied = *opts.public_key_arg;
std::ranges::transform(supplied, supplied.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (std::ranges::find(*trusted, supplied) == trusted->end()) {
std::cerr << "vbs verify: public key is not trusted\n";
return 1;
}
}
auto digest = Util::sha256_file_hex(*opts.file_arg);
if (!digest) {
std::cerr << "vbs verify: " << digest.error().message() << '\n';
@@ -2809,7 +2829,12 @@ int main(int argc, char **argv) {
.option("--version", "-v", "Package version", verify_opts.version_arg)
.option("--file", "-f", "Artifact file whose SHA-256 is signed", verify_opts.file_arg)
.option("--signature", "", "Detached signature hex", verify_opts.signature_arg)
.option("--public-key", "", "Signer public key hex", verify_opts.public_key_arg);
.option("--public-key", "", "Signer public key hex", verify_opts.public_key_arg)
.option_many("--trusted-public-key", "",
"Require the signer key to be trusted (hex; repeatable)",
verify_opts.trusted_public_keys)
.option_many("--trusted-key-file", "", "File with trusted public keys (repeatable)",
verify_opts.trusted_key_files);
add_log_flags(verify_cmd, false); // `-v` is `--version` on verify.
auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock");