obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
111 lines
3.3 KiB
C++
111 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include "certificate.hpp"
|
|
#include "certificate_storage.hpp"
|
|
#include "hashed_id8.hpp"
|
|
#include "main.hpp"
|
|
#include <vanetza/common/clock.hpp>
|
|
#include <CLI/CLI.hpp>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace pki
|
|
{
|
|
|
|
/**
|
|
* Visitor that observes expired certificates streamed by `prune_expired`.
|
|
* Methods are called once per certificate as it is encountered. The driver
|
|
* performs no per-cert buffering.
|
|
*/
|
|
class PruneExpiredVisitor
|
|
{
|
|
public:
|
|
virtual ~PruneExpiredVisitor() = default;
|
|
|
|
/**
|
|
* An expired certificate eligible for deletion.
|
|
*
|
|
* \param store backing store holding the cert; the visitor erases from it if needed
|
|
* \param label short role tag ("Root CA", "EC", "AT", "TLM") for output
|
|
* \param pubkey_hex canonical-hex name of the corresponding credential
|
|
*/
|
|
virtual void on_deletable(CertificateStorage& store, const std::string& label, const HashedId8&, const Certificate&,
|
|
const std::string& pubkey_hex)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* An expired certificate that is being skipped because it is referenced
|
|
* by station configuration and `--force` was not specified.
|
|
*/
|
|
virtual void on_skipped(const std::string& label, const HashedId8&, const Certificate&)
|
|
{
|
|
}
|
|
|
|
/// Called once after all stores have been fully iterated.
|
|
virtual void on_summary()
|
|
{
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Stream every expired certificate in the cert and ticket stores through the
|
|
* visitor. Memory is constant — no per-cert state is retained.
|
|
*
|
|
* \param now cutoff for expiry: `cert.valid_until() < now` ⇒ expired
|
|
* \param force if true, station-referenced certs go to `on_deletable` instead
|
|
* of `on_skipped`
|
|
*/
|
|
void prune_expired(const MainConfig& cfg, Clock::time_point now, bool force, PruneExpiredVisitor& visitor);
|
|
|
|
/**
|
|
* Prune expired authorization tickets and their credentials.
|
|
* `dry_run` lists without deleting.
|
|
*/
|
|
void prune_expired_tickets(const MainConfig& cfg, Clock::time_point now, bool dry_run);
|
|
|
|
/// Visitor for `prune_orphans`. Same streaming pattern.
|
|
class PruneOrphansVisitor
|
|
{
|
|
public:
|
|
virtual ~PruneOrphansVisitor() = default;
|
|
|
|
/// An orphan credential eligible for deletion, by canonical-hex name.
|
|
virtual void on_orphan(const std::string& canonical_hex)
|
|
{
|
|
}
|
|
|
|
/// A credential retained because a certificate still references it.
|
|
virtual void on_keep(const std::string& canonical_hex)
|
|
{
|
|
}
|
|
|
|
/// Called once after all credentials have been iterated.
|
|
virtual void on_summary()
|
|
{
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Stream every orphan credential through the visitor.
|
|
* A credential is orphan when its canonical-hex name does not match any public key
|
|
* referenced by a certificate in either store.
|
|
*/
|
|
void prune_orphans(const MainConfig& cfg, PruneOrphansVisitor& visitor);
|
|
|
|
/**
|
|
* Reconcile the exported AA/EA issuer certificates against the currently stored
|
|
* CTLs: remove any `.aa`/`.ea` cert whose HashedId8 is not present in the latest
|
|
* stored CTL of any trusted Root CA. Prevents issuer certs orphaned by CTL
|
|
* rotation from accumulating. `dry_run` lists without deleting.
|
|
*/
|
|
void prune_ctl(const MainConfig& cfg, bool dry_run);
|
|
|
|
// CLI subcommand tree.
|
|
std::shared_ptr<CLI::App> build_prune_command(const MainConfig&);
|
|
|
|
} // namespace pki
|
|
} // namespace vanetza
|