Skip to content

Commit 121d8a8

Browse files
committed
Add cron job to fetch trusted roots for MTC
Add a cron job that runs once per day and updates trusted roots for MTC. Remove the option to manually load in roots for the MTCA, and exclusively use the CCADB list. Substantiative differences from the static CT's CCADB cron job: - Instead of using the union of trusted roots from a manually supplied roots file and various root stores, we use the intersection of the Chrome and Mozilla trust stores, since Chrome needs to validate bootstrap chains, and we're using Mozilla's CRLite filters for revocation checks. - Instead of making the trusted roots append-only, the roots list is pruned. (If Chrome removes a trusted root, we want to remove it as well.) - Instead of each log shard storing its own roots file in KV, we just use a single file, since we're just staying in sync with the CCADB list. - Don't import the 'CT Monitoring' root.
1 parent 0d14bc0 commit 121d8a8

10 files changed

Lines changed: 229 additions & 12581 deletions

File tree

‎Cargo.lock‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/ct_worker/src/ccadb_roots_cron.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ use x509_cert::{
1717
};
1818
use x509_util::CertPool;
1919

20-
use crate::{ccadb_roots_filename, CCADB_ROOTS_NAMESPACE, CONFIG};
20+
use crate::CONFIG;
21+
22+
// A KV namespace with this binding must be configured in 'wrangler.jsonc' if
23+
// any log shards have 'enable_ccadb_roots=true'.
24+
pub(crate) const CCADB_ROOTS_NAMESPACE: &str = "ccadb_roots";
25+
26+
pub(crate) fn ccadb_roots_filename(name: &str) -> String {
27+
format!("roots_{name}.pem")
28+
}
2129

2230
#[event(scheduled)]
2331
async fn main(_event: ScheduledEvent, env: Env, _ctx: ScheduleContext) {

‎crates/ct_worker/src/lib.rs‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
55

6+
use crate::ccadb_roots_cron::{ccadb_roots_filename, update_ccadb_roots, CCADB_ROOTS_NAMESPACE};
67
use config::AppConfig;
78
use ed25519_dalek::SigningKey as Ed25519SigningKey;
89
use p256::{ecdsa::SigningKey as EcdsaSigningKey, pkcs8::DecodePrivateKey};
@@ -15,18 +16,12 @@ use tokio::sync::OnceCell;
1516
use worker::{Env, Result};
1617
use x509_util::CertPool;
1718

18-
use crate::ccadb_roots_cron::update_ccadb_roots;
19-
2019
mod batcher_do;
2120
mod ccadb_roots_cron;
2221
mod cleaner_do;
2322
mod frontend_worker;
2423
mod sequencer_do;
2524

26-
// A KV namespace with this binding must be configured in 'wrangler.jsonc' if
27-
// any log shards have 'enable_ccadb_roots=true'.
28-
const CCADB_ROOTS_NAMESPACE: &str = "ccadb_roots";
29-
3025
// Application configuration.
3126
static CONFIG: LazyLock<AppConfig> = LazyLock::new(|| {
3227
serde_json::from_str::<AppConfig>(include_str!(concat!(env!("OUT_DIR"), "/config.json")))
@@ -105,10 +100,6 @@ pub(crate) fn load_origin(name: &str) -> KeyName {
105100
.expect("invalid origin name")
106101
}
107102

108-
fn ccadb_roots_filename(name: &str) -> String {
109-
format!("roots_{name}.pem")
110-
}
111-
112103
async fn load_roots(env: &Env, name: &str) -> Result<&'static CertPool> {
113104
// Load embedded roots.
114105
ROOTS

‎crates/mtc_worker/Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ futures-executor.workspace = true
4141

4242
[dependencies]
4343
base64.workspace = true
44+
base64ct.workspace = true
45+
chrono.workspace = true
4446
config = { path = "./config", package = "mtc_worker_config" }
47+
csv.workspace = true
4548
der.workspace = true
4649
generic_log_worker.workspace = true
4750
ed25519-dalek.workspace = true
@@ -53,6 +56,7 @@ serde_json.workspace = true
5356
serde_with.workspace = true
5457
signed_note.workspace = true
5558
tlog_tiles.workspace = true
59+
tokio.workspace = true
5660
worker.workspace = true
5761
x509-cert.workspace = true
5862
x509_util.workspace = true

‎crates/mtc_worker/build.rs‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use url::Url;
1313
use x509_cert::{
1414
attr::AttributeTypeAndValue,
1515
name::{RdnSequence, RelativeDistinguishedName},
16-
Certificate,
1716
};
1817

1918
fn main() {
@@ -67,25 +66,13 @@ fn main() {
6766
}
6867
}
6968

70-
// Get and validate roots. Use 'roots.default.pem' if no environment-specific roots file is found.
71-
let mut roots_file: &str = &format!("roots.{env}.pem");
72-
if !fs::exists(roots_file).expect("failed to check if file exists") {
73-
roots_file = "roots.default.pem";
74-
}
75-
let roots =
76-
Certificate::load_pem_chain(&fs::read(roots_file).expect("failed to read roots file"))
77-
.expect("unable to decode certificates");
78-
assert!(!roots.is_empty(), "Roots file is empty");
79-
8069
// Copy to OUT_DIR.
8170
let out_dir = env::var("OUT_DIR").unwrap();
8271
fs::copy(config_file, format!("{out_dir}/config.json")).expect("failed to copy config file");
83-
fs::copy(roots_file, format!("{out_dir}/roots.pem")).expect("failed to copy roots file");
8472

8573
println!("cargo::rerun-if-env-changed=DEPLOY_ENV");
8674
println!("cargo::rerun-if-changed=config.schema.json");
8775
println!("cargo::rerun-if-changed={config_file}");
88-
println!("cargo::rerun-if-changed={roots_file}");
8976
}
9077

9178
// Validate the URL prefix according to https://datatracker.ietf.org/doc/html/rfc6962#section-4.

0 commit comments

Comments
 (0)