]> Cypherpunks repositories - gostls13.git/commit
crypto/x509: move constraint checking after chain building
authorRoland Shoemaker <roland@golang.org>
Mon, 20 Oct 2025 18:04:38 +0000 (11:04 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 24 Oct 2025 16:13:02 +0000 (09:13 -0700)
commite6cff690517e66f610bf8787a442a47d92fc14c7
tree92356f6e3e22447079c0536818f9714e7b08474e
parentf5f69a3de9a3e0b8d4e211f155853a29cd400e92
crypto/x509: move constraint checking after chain building

The standard approach to constraint checking involves checking the
constraints during chain building. This is typically done as most chain
building algorithms want to find a single chain. We don't do this, and
instead build every valid chain we can find. Because of this, we don't
_need_ to do constraint checking during the chain building stage, and
instead can defer it until we have built all of the potentially valid
chains (we already do this for EKU nesting and policy checking).

This allows us to limit the constraints we check to only chains issued
by trusted roots, which reduces the attack surface for constraint
checking, which is an annoyingly algorithmically complex process (for
now).

To maintain previous behavior, if we see an error during constraint
checking, and we end up with no valid chains, we return the first
constraint checking error, instead of a more verbose error indicating
if there were different problems during filtering. At some point we
probably should come up with a more unified error type for chain
building that can contain information about multiple failure modes.

Change-Id: I5780b3adce8538eb4c3b56ddec52f0723d39009e
Reviewed-on: https://go-review.googlesource.com/c/go/+/713240
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
src/crypto/x509/verify.go