20260701 add validation-update-03 VRS mode
This commit is contained in:
@@ -21,7 +21,7 @@ use crate::data_model::router_cert::{
|
||||
use crate::fetch::rsync::RsyncFetcher;
|
||||
use crate::parallel::config::ParallelPhase2Config;
|
||||
use crate::parallel::repo_runtime::{RepoSyncRuntime, RepoSyncRuntimeOutcome};
|
||||
use crate::policy::Policy;
|
||||
use crate::policy::{Policy, ResourceValidationMode};
|
||||
use crate::replay::archive::ReplayArchiveIndex;
|
||||
use crate::replay::delta_archive::ReplayDeltaArchiveIndex;
|
||||
use crate::report::{RfcRef, Warning};
|
||||
@@ -932,6 +932,7 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
&fresh_point,
|
||||
self.validation_time,
|
||||
self.timing.as_ref(),
|
||||
self.policy,
|
||||
if self.enable_child_certificate_validation_cache {
|
||||
Some(ChildCertificateValidationCacheContext {
|
||||
store: self.store,
|
||||
@@ -2259,12 +2260,14 @@ fn discover_children_from_fresh_snapshot_with_audit<P: PublicationPointData>(
|
||||
return Err("lazy CA certificate requires store-backed child discovery".to_string());
|
||||
}
|
||||
};
|
||||
let default_policy = Policy::default();
|
||||
discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der(
|
||||
issuer,
|
||||
issuer_ca_der,
|
||||
publication_point,
|
||||
validation_time,
|
||||
timing,
|
||||
&default_policy,
|
||||
None,
|
||||
)
|
||||
}
|
||||
@@ -2282,12 +2285,14 @@ fn discover_children_from_fresh_snapshot_with_audit_cached<P: PublicationPointDa
|
||||
return Err("lazy CA certificate requires store-backed child discovery".to_string());
|
||||
}
|
||||
};
|
||||
let default_policy = Policy::default();
|
||||
discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der(
|
||||
issuer,
|
||||
issuer_ca_der,
|
||||
publication_point,
|
||||
validation_time,
|
||||
timing,
|
||||
&default_policy,
|
||||
cache_context,
|
||||
)
|
||||
}
|
||||
@@ -2300,6 +2305,7 @@ fn discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der<
|
||||
publication_point: &P,
|
||||
validation_time: time::OffsetDateTime,
|
||||
timing: Option<&TimingHandle>,
|
||||
policy: &Policy,
|
||||
cache_context: Option<ChildCertificateValidationCacheContext<'_>>,
|
||||
) -> Result<ChildDiscoveryOutput, String> {
|
||||
let locked_files = publication_point.files();
|
||||
@@ -2906,6 +2912,7 @@ fn discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der<
|
||||
issuer.effective_as_resources.as_ref(),
|
||||
&issuer_resources_index,
|
||||
validation_time,
|
||||
policy.resource_validation_mode,
|
||||
) {
|
||||
Ok(v) => v,
|
||||
Err(CaPathError::ChildNotCa) => {
|
||||
@@ -2949,12 +2956,32 @@ fn discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der<
|
||||
|
||||
match router_result {
|
||||
Ok(router) => {
|
||||
let router_asns = match router_asns_for_resource_mode(
|
||||
&router.asns,
|
||||
issuer.effective_as_resources.as_ref(),
|
||||
policy.resource_validation_mode,
|
||||
) {
|
||||
Ok(v) => v,
|
||||
Err(detail) => {
|
||||
router_error = router_error.saturating_add(1);
|
||||
audits.push(ObjectAuditEntry {
|
||||
rsync_uri: f.rsync_uri.clone(),
|
||||
sha256_hex: sha256_hex_from_32(&f.sha256),
|
||||
kind: AuditObjectKind::RouterCertificate,
|
||||
result: AuditObjectResult::Error,
|
||||
detail: Some(format!(
|
||||
"router certificate AS resource validation failed: {detail}"
|
||||
)),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
};
|
||||
router_ok = router_ok.saturating_add(1);
|
||||
let source_object_hash = sha256_hex_from_32(&f.sha256);
|
||||
let item_effective_until = PackTime::from_utc_offset_datetime(
|
||||
router.resource_cert.tbs.validity_not_after,
|
||||
);
|
||||
for as_id in &router.asns {
|
||||
for as_id in &router_asns {
|
||||
router_keys.push(RouterKeyPayload {
|
||||
as_id: *as_id,
|
||||
ski: router.subject_key_identifier.clone(),
|
||||
@@ -3006,8 +3033,7 @@ fn discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der<
|
||||
effective_not_before,
|
||||
effective_until,
|
||||
payload: ChildCertificateCachePayload::Router {
|
||||
router_keys: router
|
||||
.asns
|
||||
router_keys: router_asns
|
||||
.iter()
|
||||
.map(|as_id| ChildCertificateCacheRouterKeyProjection {
|
||||
as_id: *as_id,
|
||||
@@ -3096,6 +3122,20 @@ fn discover_children_from_fresh_snapshot_with_audit_cached_with_issuer_der<
|
||||
validate_sub_ca_nanos = validate_sub_ca_nanos
|
||||
.saturating_add(t1.elapsed().as_nanos().min(u128::from(u64::MAX)) as u64);
|
||||
|
||||
if !validated.resource_warnings.is_empty() {
|
||||
audits.push(ObjectAuditEntry {
|
||||
rsync_uri: f.rsync_uri.clone(),
|
||||
sha256_hex: sha256_hex_from_32(&f.sha256),
|
||||
kind: AuditObjectKind::Certificate,
|
||||
result: AuditObjectResult::Ok,
|
||||
detail: Some(format!(
|
||||
"resource validation warning ({:?}): {}",
|
||||
policy.resource_validation_mode,
|
||||
validated.resource_warnings.summary()
|
||||
)),
|
||||
});
|
||||
}
|
||||
|
||||
let eff_ip_items = ip_item_count(validated.effective_ip_resources.as_ref());
|
||||
match bucketize(eff_ip_items) {
|
||||
0 => eff_ip_items_bucket_le_10 = eff_ip_items_bucket_le_10.saturating_add(1),
|
||||
@@ -3482,6 +3522,65 @@ fn is_non_router_certificate(err: &BgpsecRouterCertificatePathError) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
fn router_asns_for_resource_mode(
|
||||
router_asns: &[u32],
|
||||
issuer_effective_as: Option<&crate::data_model::rc::AsResourceSet>,
|
||||
mode: ResourceValidationMode,
|
||||
) -> Result<Vec<u32>, String> {
|
||||
let Some(issuer_effective_as) = issuer_effective_as else {
|
||||
return Err("issuer has no effective AS resources".to_string());
|
||||
};
|
||||
|
||||
match mode {
|
||||
ResourceValidationMode::Rfc6487 => {
|
||||
let outside: Vec<u32> = router_asns
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|asn| !as_resource_set_contains_asn(issuer_effective_as, *asn))
|
||||
.collect();
|
||||
if outside.is_empty() {
|
||||
Ok(router_asns.to_vec())
|
||||
} else {
|
||||
Err(format!(
|
||||
"router AS resources are not a subset of issuer effective AS resources: {outside:?}"
|
||||
))
|
||||
}
|
||||
}
|
||||
ResourceValidationMode::ValidationUpdate03 => {
|
||||
let filtered: Vec<u32> = router_asns
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|asn| as_resource_set_contains_asn(issuer_effective_as, *asn))
|
||||
.collect();
|
||||
if filtered.is_empty() {
|
||||
Err("router AS resources have empty validated resource set".to_string())
|
||||
} else {
|
||||
Ok(filtered)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn as_resource_set_contains_asn(
|
||||
resources: &crate::data_model::rc::AsResourceSet,
|
||||
asn: u32,
|
||||
) -> bool {
|
||||
let Some(choice) = resources.asnum.as_ref() else {
|
||||
return false;
|
||||
};
|
||||
match choice {
|
||||
crate::data_model::rc::AsIdentifierChoice::Inherit => false,
|
||||
crate::data_model::rc::AsIdentifierChoice::AsIdsOrRanges(items) => {
|
||||
items.iter().any(|item| match item {
|
||||
crate::data_model::rc::AsIdOrRange::Id(id) => *id == asn,
|
||||
crate::data_model::rc::AsIdOrRange::Range { min, max } => {
|
||||
*min <= asn && asn <= *max
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn select_issuer_crl_uri_for_child<'a>(
|
||||
child: &'a crate::data_model::rc::ResourceCertificate,
|
||||
crl_cache: &std::collections::HashMap<String, CachedIssuerCrl>,
|
||||
@@ -3568,6 +3667,7 @@ fn validate_subordinate_ca_cert_with_cached_issuer(
|
||||
issuer_effective_as: Option<&crate::data_model::rc::AsResourceSet>,
|
||||
issuer_resources_index: &IssuerEffectiveResourcesIndex,
|
||||
validation_time: time::OffsetDateTime,
|
||||
resource_validation_mode: crate::policy::ResourceValidationMode,
|
||||
) -> Result<ValidatedSubordinateCaLite, CaPathError> {
|
||||
let verified_crl = ensure_issuer_crl_verified(issuer_crl_rsync_uri, crl_cache, issuer_ca_der)?;
|
||||
|
||||
@@ -3584,6 +3684,7 @@ fn validate_subordinate_ca_cert_with_cached_issuer(
|
||||
issuer_effective_as,
|
||||
issuer_resources_index,
|
||||
validation_time,
|
||||
resource_validation_mode,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user