Index | Thread | Search

From:
Job Snijders <job@openbsd.org>
Subject:
Re: rpki-client: improve purpose handling
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Sat, 8 Jun 2024 06:44:33 +0000

Download raw body.

Thread
On Sat, Jun 08, 2024 at 05:35:41AM +0200, Theo Buehler wrote:
> @@ -626,7 +627,7 @@ entity_process(struct ibuf *b, struct st
>  			repo_stat_inc(rp, talid, type, STYPE_BGPSEC);
>  			break;
>  		default:
> -			errx(1, "unexpected cert purpose received");
> +			errx(1, "unexpected %s", purpose2str(cert->purpose));
>  			break;
>  		}
>  		cert_free(cert);

and

> +const char *
> +purpose2str(enum cert_purpose purpose)
> +{
> +	switch (purpose) {
> +	case CERT_PURPOSE_INVALID:
> +		return "invalid cert";
> +	case CERT_PURPOSE_TA:
> +		return "TA cert";
> +	case CERT_PURPOSE_CA:
> +		return "CA cert";
> +	case CERT_PURPOSE_EE:
> +		return "EE cert";
> +	case CERT_PURPOSE_BGPSEC_ROUTER:
> +		return "BGPsec Router cert";
> +	default:
> +		return "unknown cert";
> +	}
> +}

"unexpected unknown cert" might read a bit awkward, perhaps the
"default:" clause should print "unexpected certificate purpose"?

OK job@