Integrate signed agent catalog, tenant enrollment and HTTPS installers

This commit is contained in:
2026-11-17 15:56:18 +01:00
parent 689f326460
commit 7fd17272d5
70 changed files with 12982 additions and 327 deletions
+45
View File
@@ -0,0 +1,45 @@
//! Local verification for the separately distributed stable bootstrap updater.
use crate::{ArtifactRole, Platform, SignedRelease, TrustedContext, TrustedUpdateKey, UpdateKeyring, VerifiedRelease};
use anyhow::{Context, Result, ensure};
use rmm_domain::agent_update::{Platform as WirePlatform, ReleaseEnvelope, UpdateKeyringFile};
use std::{ffi::OsString, fs::File, io::Read, time::{SystemTime, UNIX_EPOCH}};
fn bounded(path: &OsString, limit: u64) -> Result<Vec<u8>> {
let mut bytes = Vec::new();
File::open(path)?.take(limit + 1).read_to_end(&mut bytes)?;
ensure!(bytes.len() as u64 <= limit, "bootstrap metadata too large");
Ok(bytes)
}
/// Arguments are four local files in order: pinned keyring, envelope, agent,
/// helper. The caller owns the protected staging directory and activation floor.
pub fn verify_bootstrap_files(platform: Platform, args: &[OsString]) -> Result<VerifiedRelease> {
let [keyring, envelope, agent, helper] = args else {
anyhow::bail!("four local paths required: KEYRING ENVELOPE AGENT HELPER");
};
let config: UpdateKeyringFile = serde_json::from_slice(&bounded(keyring, 16384)?)?;
ensure!(config.validate(), "invalid bootstrap keyring");
let keys = config.keys.into_iter().map(|key| {
let platform = match key.platform {
WirePlatform::LinuxX64 => Platform::LinuxX64,
WirePlatform::WindowsX64 => Platform::WindowsX64,
WirePlatform::WindowsGnuX64 => Platform::WindowsGnuX64,
};
let raw = hex::decode(key.public_key_hex)?.try_into().ok().context("Ed25519 public key length")?;
TrustedUpdateKey::new(raw, platform, key.first_sequence, key.last_sequence, key.revoked)
}).collect::<Result<Vec<_>>>()?;
let ring = UpdateKeyring::new(config.generation, keys)?;
let envelope: ReleaseEnvelope = serde_json::from_slice(&bounded(envelope, 32768)?)?;
let decoded = envelope.decode().map_err(|_| anyhow::anyhow!("invalid release envelope"))?;
let context = TrustedContext {
platform, now_utc_seconds: SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs(),
keyring_generation: config.generation, protocol_major: 1, state_schema: 1,
updater_version: 1, minimum_release_sequence: 0, active_release: None,
};
let release = crate::verify_release(SignedRelease {schema_version: envelope.schema_version,
key_id: &envelope.key_id, payload_bytes: &decoded.payload_bytes,
signature: &decoded.signature}, &ring, &context)?;
release.verify_artifact(ArtifactRole::Agent, File::open(agent)?)?;
release.verify_artifact(ArtifactRole::Helper, File::open(helper)?)?;
Ok(release)
}
+3
View File
@@ -3,8 +3,11 @@
//!
//! See docs/agent-updater-proposal.md for the separate, unfinished integration.
mod bootstrap;
mod manifest;
pub use bootstrap::verify_bootstrap_files;
pub use manifest::{
ActiveRelease, ArtifactDescriptor, ArtifactRole, MAX_ARTIFACT_BYTES, MAX_MANIFEST_BYTES,
Platform, RELEASE_SIGNATURE_DOMAIN, ReleaseManifest, ReleaseRelation, SignedRelease,
+2
View File
@@ -18,6 +18,8 @@ pub enum Platform {
LinuxX64,
#[serde(rename = "x86_64-pc-windows-msvc")]
WindowsX64,
#[serde(rename = "x86_64-pc-windows-gnu")]
WindowsGnuX64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]