From: Claudio Jeker Subject: Re: rpki-client: some validation tweaks To: Theo Buehler Cc: tech@openbsd.org Date: Thu, 12 Nov 2026 16:20:04 +0100 On Thu, Nov 12, 2026 at 03:35:31PM +0100, Theo Buehler wrote: > Three mostly unrelated things: > > In aspa_cert_info() don't bother call x509_any_inherits(). We've just > checked that there are no IP resources and exactly one (non-inheriting) > AS resource. So there is no inheritance present and we do not need to > look for the extensions and deserialize them another time to make extra > sure. > > The second one is the small valid_aspa(). This does not need to live in > a separate file and we can just inline it. > > The third bit is that for aspa, roa, rsc, and spl, we unconditionally > return 1 from sobj->validate(), which I marked with an XXX since it > confused me. One reason for this is that in normal mode we send the > object to the main process for accounting and insertion into the > vap/vrp/vsp trees if valid. In filemode invalid objects still get some > info printed this way. So add comments and remove the XXX. > > PS: Invalid mfts and taks are such that signed_object_parse() fails. > Pretty sure the parser currently relies on this for mfts to avoid > expensive work. For TAKs I have no idea. OK claudio@ > Index: aspa.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/aspa.c,v > diff -u -p -r1.51 aspa.c > --- aspa.c 12 Nov 2026 13:41:40 -0000 1.51 > +++ aspa.c 12 Nov 2026 14:26:15 -0000 > @@ -202,11 +202,6 @@ aspa_cert_info(const char *fn, void *obj > return 0; > } > > - if (x509_any_inherits(cert->x509)) { > - warnx("%s: inherit elements not allowed in EE cert", fn); > - return 0; > - } > - > return 1; > } > > @@ -215,9 +210,17 @@ aspa_validate(const char *fn, void *obj, > { > struct aspa *aspa = obj; > > - aspa->valid = valid_aspa(fn, cert, aspa); > + if (as_check_covered(aspa->custasid, aspa->custasid, > + cert->ases, cert->num_ases) > 0) { > + aspa->valid = 1; > + } else { > + warnx("%s: ASPA: uncovered Customer ASID: %u", > + fn, aspa->custasid); > + aspa->valid = 0; > + } > > - return 1; /* XXX */ > + /* return success for filemode and accounting in the main process */ > + return 1; > } > > static const ASN1_OBJECT * > Index: extern.h > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v > diff -u -p -r1.324 extern.h > --- extern.h 11 Nov 2026 19:43:11 -0000 1.324 > +++ extern.h 12 Nov 2026 14:26:16 -0000 > @@ -854,7 +854,6 @@ int valid_cert(char *, X509_STORE_CTX > int valid_rsc(const char *, struct cert *, struct rsc *); > int valid_econtent_version(const char *, const ASN1_INTEGER *, > uint64_t); > -int valid_aspa(const char *, struct cert *, struct aspa *); > int valid_uuid(const char *); > int valid_spl(const char *, struct cert *, struct spl *); > > Index: roa.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/roa.c,v > diff -u -p -r1.96 roa.c > --- roa.c 22 Oct 2026 06:15:57 -0000 1.96 > +++ roa.c 12 Nov 2026 14:26:16 -0000 > @@ -294,7 +294,8 @@ roa_validate(const char *fn, void *obj, > > roa->valid = valid_roa(fn, cert, roa); > > - return 1; /* XXX */ > + /* return success for filemode and accounting in the main process */ > + return 1; > } > > static const ASN1_OBJECT * > Index: rsc.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/rsc.c,v > diff -u -p -r1.50 rsc.c > --- rsc.c 14 Sep 2026 09:21:41 -0000 1.50 > +++ rsc.c 12 Nov 2026 14:26:16 -0000 > @@ -363,7 +363,8 @@ rsc_validate(const char *fn, void *obj, > > rsc->valid = valid_rsc(fn, cert, rsc); > > - return 1; /* XXX */ > + /* return success for more useful filemode */ > + return 1; > } > > static const ASN1_OBJECT * > Index: spl.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/spl.c,v > diff -u -p -r1.22 spl.c > --- spl.c 15 Oct 2026 20:43:32 -0000 1.22 > +++ spl.c 12 Nov 2026 14:26:16 -0000 > @@ -238,7 +238,8 @@ spl_validate(const char *fn, void *obj, > > spl->valid = valid_spl(fn, cert, spl); > > - return 1; /* XXX */ > + /* return success for filemode and accounting in the main process */ > + return 1; > } > > static const ASN1_OBJECT * > Index: validate.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/validate.c,v > diff -u -p -r1.93 validate.c > --- validate.c 12 Nov 2026 13:23:52 -0000 1.93 > +++ validate.c 12 Nov 2026 14:26:16 -0000 > @@ -563,23 +563,6 @@ valid_econtent_version(const char *fn, c > } > > /* > - * Validate the ASPA: check that the customerASID is contained. > - * Returns 1 if valid, 0 otherwise. > - */ > -int > -valid_aspa(const char *fn, struct cert *cert, struct aspa *aspa) > -{ > - > - if (as_check_covered(aspa->custasid, aspa->custasid, > - cert->ases, cert->num_ases) > 0) > - return 1; > - > - warnx("%s: ASPA: uncovered Customer ASID: %u", fn, aspa->custasid); > - > - return 0; > -} > - > -/* > * Validate whether a given string is a valid UUID. > * Returns 1 if valid, 0 otherwise. > */ > -- :wq Claudio