Skip to content

Commit 9b2335a

Browse files
author
beck
committed
Add a check_trust call to the legacy chain validation on chain add, remembering
the result in order to return the same errors as OpenSSL users expect to override the generic "Untrusted cert" error. This fixes the openssl-ruby timestamp test. ok tb@
1 parent aeae3ec commit 9b2335a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib/libcrypto/x509/x509_verify.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: x509_verify.c,v 1.40 2021/08/18 15:10:46 beck Exp $ */
1+
/* $OpenBSD: x509_verify.c,v 1.41 2021/08/18 15:32:38 beck Exp $ */
22
/*
33
* Copyright (c) 2020-2021 Bob Beck <beck@openbsd.org>
44
*
@@ -312,7 +312,7 @@ static int
312312
x509_verify_ctx_validate_legacy_chain(struct x509_verify_ctx *ctx,
313313
struct x509_verify_chain *chain, size_t depth)
314314
{
315-
int ret = 0;
315+
int ret = 0, trust;
316316

317317
if (ctx->xsc == NULL)
318318
return 1;
@@ -330,6 +330,10 @@ x509_verify_ctx_validate_legacy_chain(struct x509_verify_ctx *ctx,
330330
ctx->xsc->error = X509_V_OK;
331331
ctx->xsc->error_depth = 0;
332332

333+
trust = x509_vfy_check_trust(ctx->xsc);
334+
if (trust == X509_TRUST_REJECTED)
335+
goto err;
336+
333337
if (!x509_verify_ctx_set_xsc_chain(ctx, chain, 0, 1))
334338
goto err;
335339

@@ -354,6 +358,10 @@ x509_verify_ctx_validate_legacy_chain(struct x509_verify_ctx *ctx,
354358
if (!x509_vfy_check_policy(ctx->xsc))
355359
goto err;
356360

361+
if ((!(ctx->xsc->param->flags & X509_V_FLAG_PARTIAL_CHAIN)) &&
362+
trust != X509_TRUST_TRUSTED)
363+
goto err;
364+
357365
ret = 1;
358366

359367
err:

0 commit comments

Comments
 (0)