1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

234 Commits

Author SHA1 Message Date
tb
bfcdb7857b Drop prototype of currently nonexistent function. 2022-05-09 17:19:32 +00:00
job
04834fbd7a Add preliminary support for decoding RSC objects in filemode
This implements decoding support for draft-ietf-sidrops-rpki-rsc-06

There are three major outstanding issues:

* The wire image might still change to conform to the more widely deployed
  3779 API in libressl/openssl. IETF discussion ongoing.
* Whether the resources listed in the ResourceBlock are contained within
  the EE's RFC 3779 extension is not hooked up yet.
* There is a fair bit of duplicity between rsc.c and cert.c, look for XXX

OK tb@
2022-05-09 17:02:34 +00:00
claudio
ad462a11c7 Further refactor and cleanup filemode.c mainly remove the copies of
proc_parser_cert_validate() and proc_parser_root_cert() adjust
parse_load_certchain() and parse_load_ta() respectivly.
Also cleanup the functions in parser.c and make it possible to call
ta_parse and cert_parse with a NULL cert.
OK tb@
2022-04-21 12:59:03 +00:00
claudio
c4a9443c2d The filemode code is enough different from the regular parser code that it
makes sense to totally split it out. Duplicate proc_parser_cert_validate()
and proc_parser_root_cert() for now.

The valid_x509() plus the required static functions are moved to validate.c.
The crl_tree code moved into crl.c similar to the auth_tree handling in
cert.c. All the proc functions are now tagged with __attribute(noreturn)
which allows to remove the errx() after them.

OK tb@
2022-04-21 09:53:07 +00:00
deraadt
bdbde0472c more whitespace cleanups 2022-04-20 15:38:24 +00:00
job
530399e88e Add Concatenated JSON output in filemode (rpki-client -j -f *)
The schema is still work in progress.

OK claudio@
2022-04-20 10:46:20 +00:00
claudio
389eb2093e Change type of talsz and dependent code from size_t to int. Tal ids are
already stored as int and and talsz is the limit for these ids.
OK tb@
2022-04-19 13:52:24 +00:00
claudio
23bc08f8ba Adjust on how CRL and MFT files are verified.
Verify the CRL referenced from the mft against the mft's fileAndHash info.
If the CRL matches then load it and use it to validate this mft. If the
mft validated OK add the now also valid CRL to the auth store for later use.

Before the newest CRL was always selected but that has negative consequences
because it is common practice to revoke the previous MFT's EE cert and with
that the cache is turned useless as soon as a new CRL is used. Also there
was a possibility that the CRL used for validation of the MFT was not the
one later used.

Both RFC6486 and draft-ietf-sidrops-6486bis are unclear about this part
of the validation process. We opted in favor of the chached MFT.

With and OK tb@
2022-04-19 09:52:29 +00:00
tb
33e36affb4 Generalize sbgp_sia_location() to x509_location()
AIA and CRL URIs can reuse the code in sbgp_sia_location and thus get the
same checks as the SIA locations. This eliminates some more duplication
and makes the checks more stringent in that embedded NULs and "./" are no
longer allowed.

ok claudio
2022-04-12 08:45:34 +00:00
claudio
6cf9bac277 Adjust cache cleanup to the deficits of RRDP. Unlike rysnc, RRDP has no
method to sync the cache. It just depends on all deltas to work but has
no method to check if the result is consistent with the source.
Because of this do not unlink files which were fetched via RRDP. Instead
move them back to their .rrdp directory and hope the will be cleaned up.
This should help to keep the cache coherent in some edge cases.
OK tb@
2022-04-04 16:02:54 +00:00
claudio
ba153bd8ee Split certificate parsing in two steps. cert_parse_pre() which does
the parse and some checks and cert_parse() or ta_parse() to do the
additional checks for regular certs or TAs.
With this adjust the cert parser in -f mode to identify TAs (by checking
if it is self signed) and adjust the validation in that case. Now -f
should be able to parse and show all object correctly.
With and OK tb@
2022-04-02 12:17:53 +00:00
claudio
f999fe57db Change x509_get_aki(), x509_get_ski(), x509_get_aia(), and x509_get_crl()
to work more like x509_get_expire(). They will return an error if the
extension extraction failed but not if it was not present. The callers
must now do that check but most did already.
With this cert_parse_inner() no longer cares about TA vs non-TA certs.
Feedback and OK tb@
2022-04-01 17:22:07 +00:00
job
326af69396 Sync & permit ASPA objects to appear on Manifests
OK tb@ claudio@
2022-03-31 12:00:00 +00:00
job
9363012ef2 Name the maximum number of deltas permitted in a RRDP Notification file
OK claudio@ tb@
2022-02-14 14:46:16 +00:00
claudio
7cdd491f06 Fix serial number printing in crl_print() for large serials.
Create a common x509_convert_seqnum() function to convert the various
ASN1_INTEGERs into hexnumbers and use this for mft and crl handling.
With and OK tb@, also OK job@
2022-02-10 17:33:28 +00:00
claudio
220c707c54 Implement some code to print crls with -f.
For this introduce x509_get_time() that converts a ASN1_TIME to time_t.
Also move time2str() to print.c where it makes more sense.
This needs more work but that will happen in tree.
OK tb@
2022-02-10 15:33:47 +00:00
tb
d7e950379a Check CRLs also for manifests
There is a chicken-egg here since manifests reference the CRL themselves.
We may also have two CRLs available, in which case we check against the
one with the newer thisUpdate time.

The RFC situation is a bit of a mess with abundant complexity, unclear
recommendations and requirements and draft specs that also need to be
considered. This is a first version that works with future improvements
to be landed later.

Joint work with claudio, prompted by a question by job

ok claudio job
2022-02-08 14:53:03 +00:00
tb
4bd8ba3acf Move the guts of proc_parser_crl() into crl_parse(). This is actually
parsing the CRL, so it makes more sense to have it there. It will also
make an upcoming change easier. While there, rename free_crl() into
crl_free() for consistency with all other *_free() functions.

input/ok claudio
2022-02-08 11:51:51 +00:00
claudio
df512fbc9f Properly handle .mft files as intended by the RFC. Instead of always
selecting the newest file this opens both the new (from rrdp or rsync)
and old (valid) MFT. It then compares the manifest number and based on
that the 'newer' MFT is selected.
The MFT file and hash check is also changed to always try both locations
and selecting whatever matches up with the hash. The selction is passed
back to the the main process and used later on to open exactly the same
file as was checked against the hash.
The MFT parsing code has been split up into multiple steps so that the
files can be parsed, compared and then fully validated.
In most cases this makes no difference but it prevents replay attacks
using old but still valid files.
With and OK tb@
2022-01-28 15:30:23 +00:00
claudio
685326f577 Adjust code to handle unsupported file types a bit more graceful.
The file still needs to match its hash to make the MFT valid but then
there will only be a warning printed. Parsing of other files from that
MFT are not influenced.
OK tb@
2022-01-24 17:29:37 +00:00
claudio
7ba5db230c Handle EINTR the same way in all poll loops. In all cases restart the
poll loop. In the main process move the timeout handling for repositories
into a single function that does the timeouts and the calculation of the
timeout in one go.
OK tb@
2022-01-23 12:09:24 +00:00
claudio
24069af1d0 Simplify valid_cert() and valid_roa() by passing in struct auth instead
of looking it up again. For this valid_roa() needs to be moved up in
proc_parser_roa() also move out the assignment of the TAL id. Not the
right thing to alter an object in a validation function.
OK tb@
2022-01-23 05:59:35 +00:00
tb
043caafece Change valid_filename() ot return an enum rtype and rename it to
rtype_from_mftfile(). Move both rtype_from functions to mft.c.

ok beck claudio
2022-01-22 09:18:48 +00:00
tb
22cec6c4df Add function to determine the file type from the file name extension
rpki-client uses the same idiom to determine the file type in too many
places. Use one function that determines the appropriate RTYPE from the
file name. Add that type to struct mftfile and use this new member to
simplify queue_add_from_mft*().

input/ok claudio
2022-01-21 18:49:44 +00:00
claudio
487aa6cb3a Rename mft_check() to proc_parser_mft_check() and make it a static function. 2022-01-20 09:24:08 +00:00
claudio
f43c4d922e Implement a filemode where the passed file from the command line is
printed in human readable form and is also verified against the valid
cache of rpki-client.

To validate the file the chain is explored backwards by looking at the
Authority Information Access URI and X509v3 CRL Distribution Point of
the cert. Once the trust anchor is found this chain can be verified.

Feedback and OK job@ tb@
2022-01-19 15:50:31 +00:00
claudio
9551aa73ca Change cert_parse() and ta_parse() to no longer take a x509 handle as
argument. The x509 cert is also inside struct cert and easy to access.
Also switch auth_insert() to a void function since it can't fail.
OK tb@
2022-01-18 16:36:49 +00:00
claudio
d3c7e8168c Revert all the files that should have not been committed in last commit. 2022-01-18 16:24:55 +00:00
claudio
ba7feb83a4 Kill extra newline 2022-01-18 16:18:22 +00:00
claudio
de9b6f5d99 Cleanup the scattered OBJ_txt2obj() calls and move them into
x509_init_oid() to initalize all necessary OID objects at start.
OK tb@
2022-01-18 13:06:43 +00:00
claudio
0c3a233597 Introduce a validated cache which holds all the files that have
successfully been verified by rpki-client.

With this the rsync and rrdp directories are more of a temporary storage
location. New files are downloaded there and then moved to the valid
directory at the end. In -n mode only the valid directory is looked at with
the exception of the ta directory holding the trust anchors.
A file can now be in two different locations so adjust all the code paths
that open files to check both locations.
One nice side-effect of this is that the RRDP handling in the main process
got simplified. There is no longer the need for temporary RRDP directories.
OK tb@
2022-01-14 15:00:23 +00:00
claudio
87c7c78d66 Alter valid_filehash() to take a file descriptor instead of a path.
This is needed so that callers can allow a file to be in multiple
locations. Also move mft_check() from mft.c to parser.c.
OK tb@
2022-01-13 13:46:03 +00:00
claudio
264f4ef9cf Implement a RRDP_CLEAR message that instructs the parent to cleanup
the rrdp directory. This is used before a snapshot download to ensure
that the snapshot is applied to a clean repo.
Similar cleanup happens if the transfer fails. In that case remove the
temp directory contents only.
This uses a new function remove_contents() to remove everything below
a base directory (a bit like rm -r X/*).
OK tb@
2022-01-13 13:18:41 +00:00
claudio
100ded9e8b Change the way the parser accesses files. It now builds the file path
based on information from the repository, a local path and the filename.
This simplifies some code both in the main process and the parser.
For this to work repositories are passed to the parser before any other
entity of this repository is passed. Struct entity is extended to include
the repoid and the path along the file(name).
Input and OK tb@ & job@
2022-01-11 13:06:07 +00:00
claudio
08df5e84f3 Cleanup struct entity. Remove the unneeded has_data field, the same
information can be figured out by looking at the data pointer itself.
It is NULL when there is no data and not-NULL if there is data.
OK benno@
2021-12-29 11:37:57 +00:00
claudio
b6884e9f8f Replace two questionable size_t types. For the repo id use a unsigned int
and for the roa maxlength use unsigned char (like the prefixlen in struct
ip_addr).
With input and OK job@
2021-12-22 09:35:14 +00:00
job
cecb080267 Replace MAX_REPO_TIMEOUT with repo_timeout, which is set to 1/4th of
timeout, or if timeout is disabled set to 24 hours.

OK claudio@
2021-11-25 14:03:40 +00:00
claudio
aef00ae0fc Move some functions from rrdp.c to rrdp_util.c and hex_decode to encoding.c.
This will make it easier to write a RRDP regress test.
OK job@ deraadt@
2021-11-24 15:24:16 +00:00
job
9f2d8e54a0 Increase maximum filesize of RPKI objects to 4MB
Based on feedback from Ties de Kock

OK tb@
2021-11-10 08:34:48 +00:00
claudio
7af68c5c1d Limit the number of publication points under a given TAL.
Introduce an additional timeout for each publication point.

The limits are large enough to accomodate normal operating levels.

With and OK benno@ job@ tb@ beck@ deraadt@
2021-11-09 11:03:39 +00:00
claudio
4ef6f69353 Simplify how IP addresses and AS numbers are passed between processes.
Since they are stored in an array just blast the full array in and out
of the io buffers at once instead of iterating element by element.
It also allows to remove a lot of extra code.
OK benno@ job@
2021-11-05 10:50:41 +00:00
claudio
2cc3b5f121 Move and promote getmonotime() to an internal API function. 2021-11-04 14:24:41 +00:00
claudio
4120df8f0f Use the same spacing for all defines. 2021-11-04 14:21:19 +00:00
claudio
dc508150ce Instead of passing tal descriptions around just pass a tal id and
use a small lookup table to print the description in the output path.
OK tb@
2021-11-04 11:32:55 +00:00
claudio
36dac55ee8 Limit the number of rsync processes being spawned by stopping to accept
new requests when over the limit. Use a generous limit of 16.
OK deraadt@
2021-11-03 14:59:37 +00:00
claudio
86832a4c4e Move the MAX_CERT_DEPTH to extern.h and adjust the comments of all limits
a bit.
2021-11-03 10:50:18 +00:00
claudio
198a05209c Further simplify cert and auth handling. Move common code into auth_insert
and skip this distinction between invalid and failed certificates.
The difference between the to is getting more and more blurry.
OK tb@
2021-11-01 17:00:34 +00:00
claudio
cebe825985 Cleanup struct auth a bit. The tal description is also stored in the cert
and the filename is only used in tracewarn which is not that helpful.
OK tb@
2021-11-01 09:12:18 +00:00
claudio
93d9375cd8 Ensure that RRDP snapshot and delta files are fetched from the same host
as the notification file.
OK tb@ job@
2021-10-29 09:27:36 +00:00
job
ac69bfd295 Limit how many FileAndHash entries a single manifest may contain
OK claudio@
2021-10-28 13:51:42 +00:00
claudio
1aea4e0e02 Limit the size of the base64 blob inside the RRDP XML to be less than
MAX_FILE_SIZE after base64 decoding it. This way hostile RRDP servers
do less damage.
OK beck@ tb@
2021-10-28 11:57:00 +00:00
beck
61c641a85a Don't exit in certain cases on failures to parse x509 objects.
In most cases we already warn and continue if someone sends us malformed
x509 objects. This makes this consistent behaviour in all places
so that if someone passes in bogus X509, We end up failing their entry
and continuing rather than exiting.

We still exit on memory/system failures so that a future run of rpki
client can simply do better when the machine is perhaps less hammered
on

ok job@ claudio@
2021-10-28 09:02:19 +00:00
beck
1c69962622 Add limits on size of certain untrusted inputs
ok job@
2021-10-27 21:56:58 +00:00
claudio
2cfd2d3bd9 Move load_file() to encoding.c so that regress can use the function. 2021-10-26 16:59:19 +00:00
claudio
41edc6705a Refactor the tal parsing code to use the same load_file() and buffer
passing as done for the other parsers.
OK job@ tb@
2021-10-26 16:12:54 +00:00
claudio
803d3b9acd Also move the cert parser code away from using BIO.
OK beck@
2021-10-26 13:31:05 +00:00
claudio
cabf3a3b92 Change CMS and CRL d2i functions from their BIO version to passing the
der buffer instead. The file are loaded early in the entity processing
loop.
OK tb@
2021-10-26 10:52:49 +00:00
claudio
714f4e3f5f Move the various print functions from the regress tests into print.c.
OK tb@
2021-10-24 17:53:07 +00:00
job
dbcbf67572 Restrict the characterset for filenames on Manifests
feedback from benno@

OK claudio@
2021-10-24 12:06:16 +00:00
claudio
25f7afeed8 Rename io_buf_new to io_new_buffer and io_buf_close to io_close_buffer.
With this the write functions are all of the form io_xyz_buffer.
Remove some prototypes of functions I forgot to remove in previous commit.
OK benno@
2021-10-23 20:01:16 +00:00
claudio
7eb79a4a63 Finnally move away from blocking reads in rpki-client. The code was a
mish mash of poll, non-blocking writes and blocking reads. Using the
introduced ibuf size header in io_buf_new()/io_buf_close() the read
side can be changed to pull in a full ibuf and only start the un-marshal
once all data has been read.
OK benno@
2021-10-23 16:06:04 +00:00
claudio
2defcb5299 First step of cleanup in the io land. Introduce io_buf_new() and
io_buf_close(). These function will inject a size of the the buffer
at the beginning of the buffer and will allow the read size to be
switched to proper async IO.
OK benno@
2021-10-22 11:13:06 +00:00
job
17304ed1d4 Emit SKI in the JSON output and improve flow in x509_get_pubkey()
OK claudio@
2021-10-12 15:16:45 +00:00
job
6b83d8e365 Add support for BGPsec Router Certificates (RFC 8209)
BGPsec router keys are extracted from RPKI certificates and
emitted via the JSON output in base64 encoded form.

OK tb@ claudio@
2021-10-11 16:50:03 +00:00
job
dc8afe7e46 Make style consistent and remove an unused code path
OK tb@
2021-10-10 21:57:43 +00:00
claudio
7fd566d895 Add x509_get_expire() to extract the not-after time from a certificate
as a epoch time_t. Store the expire time for certs, crls will follow after.
OK tb@
2021-10-07 08:30:39 +00:00
job
fdfddccf0d Add rudimentary support for BGPsec router certificates
OK claudio@
2021-10-05 11:20:46 +00:00
claudio
d2e465bb28 Rework how various OIDs are compared in the code.
Instead of converting the ASN1_OBJECT into a string and comparing the
strings, convert the string into an ASN1_OBJECT once and then compare
these objects with OBJ_cmp().

Makes the code a bit easier to read and removes some repetitive conversions.
With input and OK tb@
2021-09-09 14:15:49 +00:00
claudio
6f704872d7 Add http_proxy support to rpki-client's http handler.
OK tb@
2021-09-01 08:09:41 +00:00
job
59470c3fe1 Add more checks for eContent 'version' fields.
Input from deraadt@, tb@, claudio@

OK deraadt@ claudio@ tb@
2021-07-13 18:39:39 +00:00
job
a66158d7f8 Add an 'expires' column to CSV & JSON output
The 'expires' value contains a reasonable earliest moment a VRP would expire,
in light of the currently available set of CAs and CRLs. The 'expires' value
can be used to avoid route selection based on stale data when generating VRP
sets, when faced with loss of communication between consumer and valdiator,
or validator and CA repository.

OK claudio@
2021-05-06 17:03:57 +00:00
benno
0bef1a86f2 move the RPKI_VERSION define into its own version.h file, helps portable.
ok claudio@
2021-04-14 18:05:47 +00:00
claudio
8ecbadc116 Initial commit of RRDP (The RPKI Repository Delta Protocol - RFC8182) support
in rpki-client. For now it is off by default.

All XML processing is done in its own process with minimal pledge rights.
It uses the already present https process to fetch the xml files and uses
the master porcess to handle the file IO into the repositories.
RRDP data is stored in the cache under ./rrdp/ and the first directory
is the SHA256 hash of the notify URI.

Fetching snapshots and deltas works to bring the cache up to date.
If something goes wrong rpki-client will fall back to rsync.

RRDP was implemented by Nils Fisher and integrated into rpki-client by myself.
"Time to get it in" deraadt@
2021-04-01 16:04:48 +00:00
claudio
155f32c368 Do a better job at cleaning up. Remove empty directories, scan not only the
known repositories but also clean up no longer known repositories.
With this rpki-client keeps its cache nice and shiny.
With and OK job@
2021-04-01 06:53:49 +00:00
claudio
087c464339 Move base64 and hex encoding functions into their own place.
OK tb@
2021-04-01 06:43:23 +00:00
claudio
1a998f47f2 Introduce hex_encode() to transform the aki/ski values to a string.
OK tb@
2021-03-29 12:41:34 +00:00
tb
1f25fa5db5 Inline x509_get_extensions() and remove it
Since aia, aki and ski are all represented by char *, this is an
error-prone interface - as found by job. The function doesn't do
much anyway.

ok claudio
2021-03-29 06:50:44 +00:00
job
ab5c69fdbf Add some restrictions to manifest object profile
OK tb@, feedback from claudio@
2021-03-28 16:22:17 +00:00
claudio
09b708f572 Adjust HTTP client code a bit. Add support for 304 Not Modified responses,
remove handling of 206 Partial Content (the client does not use range
headers). Report the Last-Modified timestamp back to the requestor and
switch OK to a enum value for (FAIL, OK and NOT MODIFIED).
OK tb@
2021-03-25 12:18:45 +00:00
claudio
c4f4bcd576 Add an -V option to show the version of rpki-client. For the base version
it will show just OpenBSD while -portable will show the portable version.
OK sthen@, tb@, kn@
2021-03-19 13:56:10 +00:00
claudio
8a3c435df6 Since the entity queues are per repo there is no need to store the repo id
anymore.
OK job@ tb@
2021-03-18 14:03:42 +00:00
claudio
8c2eb28888 Factor out the URI check we do in various places into valid_uri().
RRDP will add a bunch more checks so this makes even more sense.
With and OK tb@
2021-03-05 17:15:19 +00:00
claudio
67d45509f5 Factor out the SHA256 hash checks into valid_filehash() so that it can
be used by the RRDP code as well.
OK tb@
2021-03-05 16:00:00 +00:00
claudio
542b31bb4e Remove space at end of line 2021-03-05 12:33:19 +00:00
claudio
1ef5b48a83 Implement a https client as a sub-process for rpki-client. This code will
be used to fetch TA certs and later on for RRDP. Kind of unreached for now
since the default TAL files don't include https URI.
The http client is fully asynchronous and can handle multiple downloads at
the same time. This code was based on the http client in ftp(1).
OK tb@, job@
2021-03-04 13:01:41 +00:00
claudio
809b75d378 There is no longer the need to mkpathat(), the main process runs now from
the cachedir.
2021-03-02 09:23:59 +00:00
claudio
b015ea5655 Open both the cachedir and outputdir early and use fchdir(2) to
switch between the two.
OK deraadt@ job@
2021-03-02 09:08:59 +00:00
claudio
e57cd5ae85 Rename mkpath() to mkpathat() since it uses mkdirat() internally. 2021-02-22 09:46:05 +00:00
claudio
a0dad60592 Move the mkpath() call from the rsync path to the main process. This allows
to drop cpath from the rsync proc pledge (down to "stdio proc exec").
This will also make work easier with the upcoming http fetcher.
OK tb@
2021-02-19 08:14:49 +00:00
claudio
356f9aec6f Use X509_get_ext_d2i() also for x509_get_aki() and x509_get_ski().
Now x509_get_extensions() is no longer required to loop over all
extensions and the code becomes a lot simpler.
While there cleanup x509_get_crl(), as explained by tb@ X509_get_ext_d2i()
allocates memory so one needs to free the pointer at the end.
For x509_crl_get_aki() use X509_CRL_get_ext_d2i() and more or less
copy the rest over from x509_get_aki().
Warn if extensions are missing or present when not expected and also
check the the extensions are marked non-critical as required.
OK job@ tb@
2021-02-18 16:23:17 +00:00
claudio
402543e655 Rework the repository handling. Split the handling of trust anchors into
ta_lookup() while regular repositories (to fetch .mft files) are handled
by repo_lookup(). Also the cache directory layout changed; moving the
trust anchors to ./ta/{tal basename}/ the other repositories end up in
./rsync/
OK tb@
2021-02-16 08:52:00 +00:00
job
ebd5581623 get Authority Information Access (AIA) from CA & EE certs
In the context of the RPKI, the AIA extension identifies the publication
point of the certificate of the issuer of the certificate in which the
extension appears. A single reference to the publication point of the
immediate superior certificate MUST be present, except for a
"self-signed" certificate.

Thanks tb@ for review

OK claudio@
2021-02-16 07:58:30 +00:00
claudio
84c20e473c Extract the 1.3.6.1.5.5.7.48.5 (caRepository) SIA from the certificate.
Make sure that the caRepository matches the start of the URI of rpkiManifest.
The MFT must be a file inside the caRepository.
OK tb@
2021-02-08 09:22:53 +00:00
claudio
82d296570e The uri parameter of struct entity is actually a local file path.
Rename field to reduce confusion about what is what.
OK tb@
2021-02-04 14:32:01 +00:00
claudio
eae583789f Shuffle code around, move all the bits of proc_parser into parser.c.
OK tb@
2021-02-04 08:10:24 +00:00
claudio
61aab7a055 Add a mkpath() helper function to rpki-client to recursively create
directories.
OK deraadt@
2021-02-02 18:33:11 +00:00
claudio
fc5c0efe76 A while ago rpki-client was changed to validate the sha256 hashes of
files referenced in MFT files during the validation of the MFT file.
An MFT is only valid if all files are present and their hashes are valid.
Because of this there is no longer the need to check the hash when
these files are parsed later on. Remove these checks for CRT, ROA and CRL
files. Use the presence of the pkey when parsing cert files to decide
if it is a root cert or not.
OK tb@
2021-01-29 10:13:16 +00:00
claudio
08db11772c Start using the ibuf API (ibuf_dynamic, ibuf_add, ibuf_close) for writing
data between processes. This completely decouples the write side.
rpki-client can't really use the imsg framework but it can use the ibuf
bits wich imsg is built on.
OK benno@ job@
2021-01-08 08:09:07 +00:00
claudio
4be5941a58 Validate ghostbuster records (RFC 6493) but for now do nothing with the
provided vcard payload. This change verifies the certificate of the .gbr
file and makes sure it is valid (like we do for e.g. .roa files).
OK job@
2020-12-09 11:29:04 +00:00
claudio
26b5971f17 Remove the last users of io_*_write functions that call io_simple_write()
internally. This is a step in direction of more async aware io in rpki-client.
Now everything uses a buffer which is then written.
OK tb@
2020-12-02 15:31:15 +00:00
claudio
0102fb1b97 Include openssl/x509.h in extern.h since it uses a few of the typedefs from
there in structs and prototypes. Remove the openssl/ssl.h and other strange
openssl includes in the .c files that don't use openssl specific functions.
OK beck@ and tb@
2020-09-12 15:46:48 +00:00
claudio
cfc09c7b83 Move the proc_rsync and with that the rsync processing into rsync.c
main.c is too crowded
OK deraadt@
2020-09-12 10:02:01 +00:00
claudio
3d81c3df19 One tiny step towards adding RRDP support in rpki-client.
Extract the notify URL from the cert if it is available and pass it back to
the parent process. The parent process can then use this info to load the
repo via RRDP instead of rsync.
OK benno@ (some long time ago)
2020-07-28 07:35:04 +00:00
job
91da860ac5 Remove -f (force) option.
The -f option existed for some initial debugging work.

Thanks Weerd for review

OK claudio@
2020-06-30 12:52:44 +00:00
claudio
74f3d1527d Stop using rsync --delete when syncing up with the CA repos. Instead
use the files referenced in the manifests to build up a list of files
to keep and remove anything that is not in the list after doing the
full computation.
OK job@ benno@
2020-06-24 14:39:21 +00:00
deraadt
b0404f1fdb Place elapsed, user, and system time for processing in the comment headers.
ok job benno claudio
2020-04-30 13:46:39 +00:00
deraadt
0ee5ab88e4 Print statistics as comments at the top of the files which can take
comments.
ok claudio job
2020-04-28 13:41:35 +00:00
claudio
630e12ade6 Split the mft file and hash check from the mft parsing. This makes it easier
to check all files in a mft before failing and also the check is now done
after the embedded cert was checked.
This refactor was triggered because of a bug in mft_parse_econtent().
check_validity() altered rc but later failure code assumed that goto out
is good enough to return an error (rc == -1) but since rc was 1 success
was returned. This bug is now also fixed.
Bug report and OK job@
2020-04-01 14:15:49 +00:00
jca
bfe2257568 Narrow the visibility of some functions and variables local to output.c
Also make the outputs table const.
Based on a suggestion from claudio@, ok deraadt@ claudio@
2020-03-10 14:22:26 +00:00
jca
70ba94e50d Ensure that we properly flush, close and rename temporary output files
Makes sure we don't feed an incomplete/garbage file to consumers.
Input and ok claudio@ deraadt@
2020-03-09 23:50:01 +00:00
benno
2e60d9e89d generate 3 different outputs for BIRD:
- bird v1 with IPv4 routes
- bird v1 with IPv6 routes
- bird v2
when using command line option -B.
BIRD v2 output from Robert Scheck, robert AT fedoraproject DOT org
time_t cast hint from jca@, and tested by job@
ok deraadt@ claudio@
2020-03-06 17:36:42 +00:00
claudio
5b613a61b6 Don't hardcode the cache directory for rpki-client. If started as root
rpki-client will use the defaults for cache and output directory. If not
started as root users need to provide both directories as arguments.
While there switch from absolute path names to relative ones. For this
the parser and rsync process do a chdir(2) to the cache directory on startup.
OK benno@
2019-12-06 09:27:12 +00:00
deraadt
1f9a8b9481 split output management code into seperate file. iterate over output
methods using a table.  detect output truncation (for instance filesystem
full) and don't overwrite previous output
ok claudio
2019-12-04 12:40:17 +00:00
deraadt
747ff6ba73 output_createtmp() remembers the true name, so output_finish() does not
need to replay it.
2019-12-02 02:11:13 +00:00
deraadt
ed26e04b57 Tweak rpki-client to create all 4 output file formats from a single
compute, based upon flags.  OpenBGPD compatible format by default if
no options, to integrate with bgpd.conf and bgpctl reload.  Adapt
mtree and stuff.  This will receive further refactoring...
ok benno job
2019-11-30 02:31:12 +00:00
claudio
e669621f7c Use the AKI embedded in the CRL to store the crls. This way the AKI from
the cert can be used to load the correct CRL. This simplifies the code
even further.
OK benno@, beck@ agrees that this is the right way to do it
2019-11-29 04:40:04 +00:00
deraadt
43dfc6a83c If run as root, priv-drop to _rpki-client.
If no output file is specified, output to the bgpd/bgpd.conf-compatible
/var/db/rpki-client/roa file.
ok claudio and benno
2019-11-29 04:04:08 +00:00
claudio
a079bbf85d Convert the auths array into an RB tree indexed by SKI. For fast lookups
the parent auth struct is stored as a pointer so walking up the certificate
chain remains simple. Doing this replaces a few slow lookups and speeds up
rpki-client by a factor of 2.
OK benno@
2019-11-28 20:36:17 +00:00
deraadt
4cefd9474e Output to a temporary file, which gets renamed on success. This will
work much better with bgpd.conf include automation.
ok claudio benno
2019-11-28 20:23:09 +00:00
benno
51b3988bb8 To verify a manifest, a roa, or a certificate, we check its signature
against the CA one layer above it. This check just needs to use the
certificate revocation list published by that CA.

Instead of loading all CRLs we find into the trust store, we create a
STACK_OF(X509_CRL), push the onto it and use it with
X509_STORE_CTX_set0_crls(ctx, crls);

The x509_get_crl() function to retrieve a crl path from an X509 object
is written by claudio@.
ok claudio@
2019-11-28 03:22:59 +00:00
benno
4f1d433364 whitespace 2019-11-27 17:14:20 +00:00
benno
730721603a Only store ta certs in the trust store and build chains of the
intermediate certificates for use in X509_STORE_CTX_init(). To do that
save the X509 cert in struct cert.
claudio sees > 2x speed increase.

ok claudio@ and feedback from jsing@ and beck@.
2019-11-27 17:08:12 +00:00
benno
cbcd0d1ab6 knf, make types grepable. ok claudio@ 2019-11-27 04:32:09 +00:00
claudio
6a48a44272 Refactor tal code a bit. Move the file reader back into tal.c so that the
regress test is able to use it.
OK deraadt@
2019-11-04 09:35:43 +00:00
claudio
397f8a58d6 Handle the TAL files in the master process and pass them as buffer to the
parser process. This way the parser never needs to read outside of the
cache directory which makes the unveil simpler. Additionally rsync_uri_parse
no longer needs to know about .tal files so there is now no chance to sneak
in a .tal file later on.
OK deraadt@
2019-10-31 08:36:43 +00:00
claudio
5a1f8137e2 Add an output format for bird and one doing CSV. Also update the manpage
to include all the changes.
2019-10-16 17:43:29 +00:00
claudio
a382efa298 Rewrite the output handling of rpki-client and add an option to dump the
data in JSON format. To make the JSON output the same as the output of the
RIPE rpki-validator the basename of the TAL had to be added and passed around
in rpki-client. Additinally the VRPs are now stored in an RB tree in the
main process instead of keeping them per ROA object. This changes the sort
order to be in network order and no longer just lexographical.
Agreed by job@ deraadt@
2019-10-08 10:04:36 +00:00
claudio
2d3101137f Change the arguments to rpki-client a bit. Instead of listing all TAL files
as arguments rpki-client will now load the TAL installed in /etc/rpki by
default. For debug reasons an option -t tal is added to pass in TAL files
by hand. The argument is now instead the filename of the output file.
Now `rpki-client roa.conf` will do what you need which is a lot nicer.
Agreed by deraadt@ job@ to be a step in the right direction.
2019-08-20 16:01:52 +00:00
claudio
8825d98844 Show the most common warnings only if verbose is set. Most of these warnings
were shown because of an inconsistent rpki database and is no real problem.
OK florian@
2019-08-13 13:27:26 +00:00
deraadt
23c49d5288 use $OpenBSD$ headers 2019-06-19 16:30:36 +00:00
claudio
22bf19692e Instead of the strange ASN.1 encoding of IP addresses with a size in bytes
and a count of how many bits of the last byte are unused switch to a much
more normal prefixlen in bits encoding for internal use. This makes the
code easier to understand. Also switch to inet_ntop() for converting a
struct ip_addr into a string.
OK job@
2019-06-19 15:47:34 +00:00
deraadt
80272c4992 indentation adjustments, in particular near warn statements
ok claudio
2019-06-19 04:21:43 +00:00
deraadt
e1e433b451 This portable code knocking out pledge or unveil is better done
as a C stub, rather than #define.
Anyways, this "-portable by default" approach is not the OpenBSD way.
2019-06-17 15:02:39 +00:00
job
9a7e9e7f88 ../../../logmessage 2019-06-17 14:31:30 +00:00