[control] Domi CA and UI sign-in: intermediate renewal by CSR with manual offline signing, domi host certificates, device requests approved by code, one-time PKCS#12 installs, revocation; Remote-User trusted only with edge's per-boot proof
This commit is contained in:
@@ -187,7 +187,16 @@ impl Shared {
|
||||
|
||||
fn install(&self, rt: Arc<Runtime>) {
|
||||
self.certs.replace_files(rt.file_certs.clone());
|
||||
self.devices.replace(rt.device_trust.clone());
|
||||
// Read the device files again: the runtime may be older than the latest allow list
|
||||
// (a revert after a revocation must not let a revoked device back in).
|
||||
let trust = match fresh_trust(&rt) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
log::error!(target: "ianitor::tls", "{e}; keeping the device check this config was built with");
|
||||
rt.device_trust.clone()
|
||||
}
|
||||
};
|
||||
self.devices.replace(trust);
|
||||
self.current.store(rt);
|
||||
self.generation.fetch_add(1, Ordering::SeqCst);
|
||||
self.notify();
|
||||
@@ -496,3 +505,36 @@ fn poisoned() -> AdminError {
|
||||
fn short(sha: &str) -> &str {
|
||||
sha.get(..12).unwrap_or(sha)
|
||||
}
|
||||
|
||||
/// The device check for a runtime, built from the files as they are now.
|
||||
fn fresh_trust(rt: &Runtime) -> Result<Option<Arc<crate::tls::DeviceTrust>>, String> {
|
||||
let Some(dc) = &rt.cfg.device_certs else {
|
||||
return Ok(None);
|
||||
};
|
||||
let hosts: std::collections::HashSet<String> = rt
|
||||
.cfg
|
||||
.hosts
|
||||
.iter()
|
||||
.filter(|h| h.device_certs)
|
||||
.map(|h| h.hostname.clone())
|
||||
.collect();
|
||||
if hosts.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
let ca = std::fs::read(&dc.ca).map_err(|e| format!("cannot read {}: {e}", dc.ca))?;
|
||||
let allow = std::fs::read(&dc.allow).map_err(|e| format!("cannot read {}: {e}", dc.allow))?;
|
||||
crate::tls::DeviceTrust::new(&ca, &allow, hosts).map(|t| Some(Arc::new(t)))
|
||||
}
|
||||
|
||||
impl Shared {
|
||||
/// Re-read the device CA bundle and allow list now (control calls this after an issue
|
||||
/// or a revocation; allowed during a trial). Returns how many devices are allowed.
|
||||
pub fn reload_device_trust(&self) -> Result<usize, String> {
|
||||
let rt = self.current();
|
||||
let t = fresh_trust(&rt)?;
|
||||
let n = t.as_ref().map_or(0, |t| t.allowed());
|
||||
self.devices.replace(t);
|
||||
log::info!(target: "ianitor::tls", "device certificates re-read: {n} allowed");
|
||||
Ok(n)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user