Skip to content

Commit

Permalink
Take reference time into account in qualification
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasValvekens committed Nov 17, 2024
1 parent 1b27a63 commit c2f10c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyhanko/sign/validation/qualified/assess.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def check_entity_cert_qualified(
prelim_status = replace(prelim_status, qualified=True)

statuses_found: List[Tuple[CAServiceInformation, QualifiedStatus]] = []
for sd in self._registry.applicable_tsps_on_path(path):
for sd in self._registry.applicable_tsps_on_path(path, reference_time):
# For this subtlety, see the hanging para in the beginning of
# section 4 in the CEF eSignature DSS validation algorithm doc
putative_status = QualificationAssessor._apply_sd_qualifications(
Expand Down
14 changes: 8 additions & 6 deletions pyhanko/sign/validation/qualified/tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
_TRSTSVC_URI_BASE = 'http://uri.etsi.org/TrstSvc'
_TRUSTEDLIST_URI_BASE = f'{_TRSTSVC_URI_BASE}/TrustedList'


__all__ = [
'CAServiceInformation',
'TSPRegistry',
Expand Down Expand Up @@ -185,14 +184,17 @@ def applicable_service_definitions(
def known_authorities(self) -> Iterable[Authority]:
return self._cert_to_si.keys()

# TODO take date into account (and properly track it
# for service definitions)
def applicable_tsps_on_path(
self,
path: ValidationPath,
self, path: ValidationPath, moment: datetime
) -> Generator[CAServiceInformation, None, None]:
for ca in path.iter_authorities():
yield from self.applicable_service_definitions(ca)
for service in self.applicable_service_definitions(ca):
valid_from = service.base_info.valid_from
valid_until = service.base_info.valid_until
if valid_from <= moment and (
not valid_until or valid_until >= moment
):
yield service


class TSPTrustManager(TrustManager):
Expand Down
2 changes: 1 addition & 1 deletion pyhanko_tests/test_trusted_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def test_tl_override_processing(
DUMMY_BASE_INFO = tsp.BaseServiceInformation(
service_type=eutl_parse.CA_QC_URI,
service_name='Dummy',
valid_from=datetime(2020, 11, 1, tzinfo=timezone.utc),
valid_from=datetime(2015, 11, 1, tzinfo=timezone.utc),
valid_until=None,
provider_certs=(TESTING_CA_QUALIFIED.get_cert('root'),),
additional_info_certificate_type=frozenset([tsp.QcCertType.QC_ESIGN]),
Expand Down

0 comments on commit c2f10c6

Please sign in to comment.