summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeck <>2020-09-12 14:14:02 +0000
committerbeck <>2020-09-12 14:14:02 +0000
commitd7dfc10134411f17602aa3f2d5224ccb44f6701c (patch)
tree2e8cba8a60876b7612ba25a26b032d0fb5f4da17
parentca7e93e1e5543d9778b24369e5b780da61dd26bf (diff)
downloadopenbsd-d7dfc10134411f17602aa3f2d5224ccb44f6701c.tar.gz
openbsd-d7dfc10134411f17602aa3f2d5224ccb44f6701c.tar.bz2
openbsd-d7dfc10134411f17602aa3f2d5224ccb44f6701c.zip
Change over to use the new x509 name constraints verification.
ok jsing@
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 126e0f3000..28dbf60c38 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vfy.c,v 1.73 2020/05/31 17:23:39 jsing Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.74 2020/09/12 14:14:02 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -75,6 +75,7 @@
75#include <openssl/x509v3.h> 75#include <openssl/x509v3.h>
76#include "asn1_locl.h" 76#include "asn1_locl.h"
77#include "vpm_int.h" 77#include "vpm_int.h"
78#include "x509_internal.h"
78#include "x509_lcl.h" 79#include "x509_lcl.h"
79 80
80/* CRL score values */ 81/* CRL score values */
@@ -782,33 +783,11 @@ end:
782static int 783static int
783check_name_constraints(X509_STORE_CTX *ctx) 784check_name_constraints(X509_STORE_CTX *ctx)
784{ 785{
785 X509 *x; 786 if (!x509_constraints_chain(ctx->chain, &ctx->error,
786 int i, j, rv; 787 &ctx->error_depth)) {
787 788 ctx->current_cert = sk_X509_value(ctx->chain, ctx->error_depth);
788 /* Check name constraints for all certificates */ 789 if (!ctx->verify_cb(0, ctx))
789 for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--) { 790 return 0;
790 x = sk_X509_value(ctx->chain, i);
791 /* Ignore self issued certs unless last in chain */
792 if (i && (x->ex_flags & EXFLAG_SI))
793 continue;
794 /* Check against constraints for all certificates higher in
795 * chain including trust anchor. Trust anchor not strictly
796 * speaking needed but if it includes constraints it is to be
797 * assumed it expects them to be obeyed.
798 */
799 for (j = sk_X509_num(ctx->chain) - 1; j > i; j--) {
800 NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc;
801 if (nc) {
802 rv = NAME_CONSTRAINTS_check(x, nc);
803 if (rv != X509_V_OK) {
804 ctx->error = rv;
805 ctx->error_depth = i;
806 ctx->current_cert = x;
807 if (!ctx->verify_cb(0, ctx))
808 return 0;
809 }
810 }
811 }
812 } 791 }
813 return 1; 792 return 1;
814} 793}