28 Commits

Author SHA1 Message Date
dandds
0b5acde4c4 Stream-parse CRLs for caching file locations.
AT-AT needs to maintain a key-value CRL cache where each key is the DER
byte-string of the issuer and the value is a dictionary of the CRL file
path and expiration. This way when it checks a client certificate, it
can load the correct CRL by comparing the issuers. This is preferable to
loading all of the CRLs in-memory. However, it still requires that AT-AT
load and parse each CRL when the application boots. Because of the size
of the CRLs and their parsed, in-memory size, this leads to the
application spiking to use nearly 900MB of memory (resting usage is
around 50MB).

This change introduces a small function to ad-hoc parse the CRL and
obtain the information in the CRL we need: the issuer and the
expiration. It does this by reading the CRL byte-by-byte until it
reaches the ASN1 sequence that corresponds to the issuer, and then looks
ahead to find the nextUpdate field (i.e., the expiration date). The
CRLCache class uses this function to build its cache and JSON-serializes
the cache to disk. If another AT-AT application process finds the
serialized version, it will load that copy instead of rebuilding it. It
also entails a change to the function signature for the init method of
CRLCache: now it expects the CRL directory as its second argument,
instead of a list of locations.

The Python script invoked by `script/sync-crls` will rebuild the
location cache each time it's run. This means that when the Kubernetes
CronJob for CRLs runs, it will refresh the cache each time. When a new
application container boots, it will get the refreshed cache.

This also adds a nightly CircleCI job to sync the CRLs and test that the
ad-hoc parsing function returns the same result as a proper parsing
using the Python cryptography library. This provides extra insurance
that the function is returning correct results on real data.
2019-11-04 08:36:03 -05:00
dandds
bd8a469e93 Fix tests that were broken by a fixture CRL expiring.
Adjust the broken tests to use our dynamic fixtures for PKI files. Some
tests still rely on these fixtures, but this is a minimal patch to get
the test suite passing again. Eventually all tests should use the pytest
fixtures.
2019-07-10 11:11:49 -04:00
dandds
dff72422f0 log access attempts in access decorator 2019-03-22 06:31:20 -04:00
Montana
ceee1f69d2 Rely on fixture to change app config 2019-03-14 13:46:52 -04:00
Montana
280775fa66 Fix test that produces CRLRevocationException 2019-03-14 13:44:54 -04:00
Montana
5782c30a7d Use pytest fixture for app with non default configs 2019-03-14 13:42:12 -04:00
Montana
a1ebedb382 Add another CRLCache test 2019-03-14 13:42:12 -04:00
Montana
2eeb548458 Move crl fixtures to conftest 2019-03-14 13:42:12 -04:00
Montana
30cd77ff98 Test AuthenticationContext 2019-03-14 13:42:12 -04:00
Montana
720859efb6 Ugly implementation for CRLInvalidException 2019-03-14 13:42:12 -04:00
dandds
22af868557 sync CRLs if one in the cache is out of date 2019-02-27 05:51:50 -05:00
dandds
b420ff2e5b record CRL expiration in CRL cache 2019-02-27 05:51:50 -05:00
dandds
9aa15d57e8 CRL Provider for syncing CRLs from cached source 2019-02-27 05:51:50 -05:00
dandds
9d141d1ea4 clarify test of missing CRL 2019-01-18 10:33:43 -05:00
dandds
0457b0a508 handle exceptions when loading CRLs 2019-01-17 14:20:04 -05:00
dandds
becaec8d42 no op version of CRL cache for disabling crl check 2019-01-17 10:28:40 -05:00
dandds
5656523ad6 catch additional CRL download exception 2019-01-14 15:17:45 -05:00
richard-dds
daa8634cb4 Format project 2018-08-23 16:25:36 -04:00
dandds
c8bcde48ec fix multi-step certificate chain bug in CRL check 2018-08-20 12:37:33 -04:00
dandds
be52c8b9b2 make crl_check a CRLCache method 2018-08-17 11:13:01 -04:00
dandds
ca2763fd03 handle case where certificate issuer is not in existing cache 2018-08-17 11:02:20 -04:00
dandds
714c82364f more specific name for CRL revocation exception 2018-08-17 10:48:49 -04:00
dandds
1f7848741b simpler CRL implementation; load as-need because we cannot marshal openssl objects in python 2018-08-16 15:54:42 -04:00
dandds
e931560dc6 more straightforward crl check function 2018-08-16 14:45:46 -04:00
dandds
2db84fb19a build individual x509 stores for each CRL 2018-08-16 14:21:03 -04:00
dandds
3d9987ac13 use if-modified-since header to optimize CRL updates 2018-08-13 13:56:20 -04:00
dandds
4da814aaf4 move crl validator 2018-08-09 15:01:43 -04:00
dandds
f0a7bfcd0e add CRL functionality from authnid 2018-08-06 10:44:00 -04:00