20260510 增加strict策略模式并隔离多TA失败
This commit is contained in:
@@ -28,6 +28,17 @@ const RFC_CRLDP: &[RfcRef] = &[RfcRef("RFC 6487 §4.8.6")];
|
||||
const RFC_CRLDP_AND_LOCKED_PACK: &[RfcRef] =
|
||||
&[RfcRef("RFC 6487 §4.8.6"), RfcRef("RFC 9286 §4.2.1")];
|
||||
|
||||
fn decode_resource_certificate_with_policy(
|
||||
der: &[u8],
|
||||
policy: &Policy,
|
||||
) -> Result<ResourceCertificate, crate::data_model::rc::ResourceCertificateDecodeError> {
|
||||
if policy.strict.name {
|
||||
ResourceCertificate::decode_der_with_strict_name(der)
|
||||
} else {
|
||||
ResourceCertificate::decode_der(der)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct VerifiedIssuerCrl {
|
||||
crl: crate::data_model::crl::RpkixCrl,
|
||||
@@ -178,11 +189,15 @@ pub fn process_publication_point_for_issuer_with_options<P: PublicationPointData
|
||||
let mut audit: Vec<ObjectAuditEntry> = Vec::new();
|
||||
|
||||
// Enforce that `manifest_bytes` is actually a manifest object.
|
||||
let _manifest = ManifestObject::decode_der(manifest_bytes)
|
||||
.expect("publication point snapshot manifest decodes");
|
||||
let _manifest = ManifestObject::decode_der_with_strict_options(
|
||||
manifest_bytes,
|
||||
policy.strict.cms_der,
|
||||
policy.strict.name,
|
||||
)
|
||||
.expect("publication point snapshot manifest decodes");
|
||||
|
||||
// Decode issuer CA once; if it fails we cannot validate ROA/ASPA EE certificates.
|
||||
let issuer_ca = match ResourceCertificate::decode_der(issuer_ca_der) {
|
||||
let issuer_ca = match decode_resource_certificate_with_policy(issuer_ca_der, policy) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
stats.publication_point_dropped = true;
|
||||
@@ -349,6 +364,8 @@ pub fn process_publication_point_for_issuer_with_options<P: PublicationPointData
|
||||
validation_time,
|
||||
timing,
|
||||
collect_vcir_local_outputs,
|
||||
policy.strict.cms_der,
|
||||
policy.strict.name,
|
||||
);
|
||||
match result.outcome {
|
||||
Ok(mut ok) => {
|
||||
@@ -457,6 +474,8 @@ pub fn process_publication_point_for_issuer_with_options<P: PublicationPointData
|
||||
validation_time,
|
||||
timing,
|
||||
collect_vcir_local_outputs,
|
||||
policy.strict.cms_der,
|
||||
policy.strict.name,
|
||||
) {
|
||||
Ok((att, local_output)) => {
|
||||
stats.aspa_ok += 1;
|
||||
@@ -739,6 +758,8 @@ pub(crate) struct OwnedRoaTask {
|
||||
issuer_effective_as: Option<crate::data_model::rc::AsResourceSet>,
|
||||
validation_time: time::OffsetDateTime,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
pub(crate) submitted_at: Option<Instant>,
|
||||
}
|
||||
|
||||
@@ -844,6 +865,8 @@ fn validate_owned_roa_task(worker_index: usize, task: OwnedRoaTask) -> RoaTaskRe
|
||||
task.validation_time,
|
||||
None,
|
||||
task.collect_vcir_local_outputs,
|
||||
task.strict_cms_der,
|
||||
task.strict_name,
|
||||
)
|
||||
.map(|(vrps, local_outputs)| RoaTaskOk {
|
||||
vrps,
|
||||
@@ -881,6 +904,8 @@ pub(crate) struct ParallelObjectsStage {
|
||||
issuer_effective_as: Option<crate::data_model::rc::AsResourceSet>,
|
||||
validation_time: time::OffsetDateTime,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
warnings: Vec<Warning>,
|
||||
stats: ObjectsStats,
|
||||
audit: Vec<ObjectAuditEntry>,
|
||||
@@ -907,6 +932,8 @@ impl ParallelObjectsStage {
|
||||
issuer_effective_as: self.issuer_effective_as.clone(),
|
||||
validation_time: self.validation_time,
|
||||
collect_vcir_local_outputs: self.collect_vcir_local_outputs,
|
||||
strict_cms_der: self.strict_cms_der,
|
||||
strict_name: self.strict_name,
|
||||
submitted_at: None,
|
||||
})
|
||||
.collect()
|
||||
@@ -928,6 +955,7 @@ impl ParallelObjectsStage {
|
||||
pub(crate) fn prepare_publication_point_for_parallel_roa<P: PublicationPointData>(
|
||||
publication_point_id: u64,
|
||||
publication_point: &P,
|
||||
policy: &Policy,
|
||||
issuer_ca_der: &[u8],
|
||||
issuer_ca_rsync_uri: Option<&str>,
|
||||
issuer_effective_ip: Option<&crate::data_model::rc::IpResourceSet>,
|
||||
@@ -950,10 +978,14 @@ pub(crate) fn prepare_publication_point_for_parallel_roa<P: PublicationPointData
|
||||
.count();
|
||||
let mut audit: Vec<ObjectAuditEntry> = Vec::new();
|
||||
|
||||
let _manifest = ManifestObject::decode_der(manifest_bytes)
|
||||
.expect("publication point snapshot manifest decodes");
|
||||
let _manifest = ManifestObject::decode_der_with_strict_options(
|
||||
manifest_bytes,
|
||||
policy.strict.cms_der,
|
||||
policy.strict.name,
|
||||
)
|
||||
.expect("publication point snapshot manifest decodes");
|
||||
|
||||
let issuer_ca = match ResourceCertificate::decode_der(issuer_ca_der) {
|
||||
let issuer_ca = match decode_resource_certificate_with_policy(issuer_ca_der, policy) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
stats.publication_point_dropped = true;
|
||||
@@ -1109,6 +1141,8 @@ pub(crate) fn prepare_publication_point_for_parallel_roa<P: PublicationPointData
|
||||
issuer_effective_as: issuer_effective_as.cloned(),
|
||||
validation_time,
|
||||
collect_vcir_local_outputs,
|
||||
strict_cms_der: policy.strict.cms_der,
|
||||
strict_name: policy.strict.name,
|
||||
warnings,
|
||||
stats,
|
||||
audit,
|
||||
@@ -1193,6 +1227,8 @@ pub(crate) fn reduce_parallel_roa_stage(
|
||||
stage.validation_time,
|
||||
timing,
|
||||
stage.collect_vcir_local_outputs,
|
||||
stage.strict_cms_der,
|
||||
stage.strict_name,
|
||||
) {
|
||||
Ok((att, local_output)) => {
|
||||
stats.aspa_ok += 1;
|
||||
@@ -1254,6 +1290,7 @@ fn process_publication_point_for_issuer_parallel_roa_inner<P: PublicationPointDa
|
||||
let stage = match prepare_publication_point_for_parallel_roa(
|
||||
0,
|
||||
publication_point,
|
||||
_policy,
|
||||
issuer_ca_der,
|
||||
issuer_ca_rsync_uri,
|
||||
issuer_effective_ip,
|
||||
@@ -1411,6 +1448,8 @@ pub(crate) fn validate_roa_task_serial(
|
||||
validation_time: time::OffsetDateTime,
|
||||
timing: Option<&TimingHandle>,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
) -> RoaTaskResult {
|
||||
let sha256_hex = sha256_hex_from_32(&task.file.sha256);
|
||||
let outcome = process_roa_with_issuer(
|
||||
@@ -1427,6 +1466,8 @@ pub(crate) fn validate_roa_task_serial(
|
||||
validation_time,
|
||||
timing,
|
||||
collect_vcir_local_outputs,
|
||||
strict_cms_der,
|
||||
strict_name,
|
||||
)
|
||||
.map(|(vrps, local_outputs)| RoaTaskOk {
|
||||
vrps,
|
||||
@@ -1459,11 +1500,17 @@ fn process_roa_with_issuer(
|
||||
validation_time: time::OffsetDateTime,
|
||||
timing: Option<&TimingHandle>,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
) -> Result<(Vec<Vrp>, Vec<VcirLocalOutput>), ObjectValidateError> {
|
||||
let _decode = timing
|
||||
.as_ref()
|
||||
.map(|t| t.span_phase("objects_roa_decode_and_validate_total"));
|
||||
let roa = RoaObject::decode_der(file.bytes().map_err(ObjectValidateError::BytesLoad)?)?;
|
||||
let roa = RoaObject::decode_der_with_strict_options(
|
||||
file.bytes().map_err(ObjectValidateError::BytesLoad)?,
|
||||
strict_cms_der,
|
||||
strict_name,
|
||||
)?;
|
||||
drop(_decode);
|
||||
|
||||
let _ee_profile = timing
|
||||
@@ -1575,11 +1622,17 @@ fn process_roa_with_issuer_parallel_cached(
|
||||
validation_time: time::OffsetDateTime,
|
||||
timing: Option<&TimingHandle>,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
) -> Result<(Vec<Vrp>, Vec<VcirLocalOutput>), ObjectValidateError> {
|
||||
let _decode = timing
|
||||
.as_ref()
|
||||
.map(|t| t.span_phase("objects_roa_decode_and_validate_total"));
|
||||
let roa = RoaObject::decode_der(file.bytes().map_err(ObjectValidateError::BytesLoad)?)?;
|
||||
let roa = RoaObject::decode_der_with_strict_options(
|
||||
file.bytes().map_err(ObjectValidateError::BytesLoad)?,
|
||||
strict_cms_der,
|
||||
strict_name,
|
||||
)?;
|
||||
drop(_decode);
|
||||
|
||||
let _ee_profile = timing
|
||||
@@ -1697,11 +1750,17 @@ fn process_aspa_with_issuer(
|
||||
validation_time: time::OffsetDateTime,
|
||||
timing: Option<&TimingHandle>,
|
||||
collect_vcir_local_outputs: bool,
|
||||
strict_cms_der: bool,
|
||||
strict_name: bool,
|
||||
) -> Result<(AspaAttestation, Option<VcirLocalOutput>), ObjectValidateError> {
|
||||
let _decode = timing
|
||||
.as_ref()
|
||||
.map(|t| t.span_phase("objects_aspa_decode_and_validate_total"));
|
||||
let aspa = AspaObject::decode_der(file.bytes().map_err(ObjectValidateError::BytesLoad)?)?;
|
||||
let aspa = AspaObject::decode_der_with_strict_options(
|
||||
file.bytes().map_err(ObjectValidateError::BytesLoad)?,
|
||||
strict_cms_der,
|
||||
strict_name,
|
||||
)?;
|
||||
drop(_decode);
|
||||
|
||||
let _ee_profile = timing
|
||||
|
||||
Reference in New Issue
Block a user