The previous solution (ad-hoc stream-parsing the CRLs to obtain their issuers and nextUpdate) was too cute. It began breaking on CRLs that had an addition hex 0x30 byte somewhere in their header. I thought that 0x30 was a reserved character only to be used for tags in ASN1 encoded with DER; turns out that's not true. Rather than write a full-fledged ASN1 stream-parser, the simplest solution is to just maintain the list of issuers as a constant in the codebase. This is fine because the issuer for a specific CRL URI should not change. If it does, we've probably got bigger problems. This also removes the Flask app's functionality for updating the local CRL cache. This is being handled out-of-band by a Kubernetes CronJob and is not a concern of the app's. This means that instances of the CRLCache do not have to explicitly track expirations for CRLs. Previously, the in-memory dictionary or CRL issuers and locations included expirations; now it is flattened to not include that information. The CRLCache class has been updated to accept a crl_list kwargs so that unit tests can provide their own alternative CRL lists, since we now hard-code the expected CRLs and issuers. The nightly CRL check job has been updated to check that the hard-coded list of issuers matches what we get when we actually sync the CRLs.
17 lines
420 B
Python
17 lines
420 B
Python
import os
|
|
import pytest
|
|
|
|
from atst.domain.authnid.crl.util import crl_local_path, CRL_LIST
|
|
|
|
from tests.utils import parse_for_issuer_and_next_update
|
|
|
|
|
|
CRL_DIR = "crls"
|
|
|
|
|
|
@pytest.mark.parametrize("crl_uri, issuer", CRL_LIST)
|
|
def test_crl_scan_against_parse(crl_uri, issuer):
|
|
crl_path = crl_local_path(CRL_DIR, crl_uri)
|
|
parsed_der = parse_for_issuer_and_next_update(crl_path)
|
|
assert issuer == parsed_der.hex()
|