Commit Graph

37 Commits

Author SHA1 Message Date
leigh-mil
c2814416fb Update atst to atat 2020-03-04 11:51:15 -05:00
dandds
3ddfc5c179 Fix bug in static CRL test.
A CRL test that relies on fixtures files was not getting a working copy
of the relevant CRL list it needed. This also adds a setup function to
the relevant test module so that we can clear and rebuild the CRL
location cache for the fixtures.
2019-11-14 14:12:07 -05:00
dandds
1b6239893b Maintain static list of CRL URIs and issuers.
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.
2019-11-12 05:43:11 -05:00
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
effec85cf9 Raise Error Code 008 for invalid CRLs 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
855c0bc3c4 tests for AuthenticationContext 2018-08-09 15:01:43 -04:00
dandds
4da814aaf4 move crl validator 2018-08-09 15:01:43 -04:00
dandds
05de0665d4 basic implementation of email parsing for CAC user login 2018-08-09 15:01:06 -04:00
dandds
c0d72cd0d6 utility function for getting user email from x509 certificate 2018-08-09 15:01:06 -04:00
dandds
b89dd07fef use DOD_SDN from mocks 2018-08-06 14:14:11 -04:00
dandds
4f8c0b81a0 import authnid sdn utils 2018-08-06 10:44:00 -04:00
dandds
f0a7bfcd0e add CRL functionality from authnid 2018-08-06 10:44:00 -04:00