Skip to content

Commit

Permalink
x509roots: catch the zero-roots case when generating the bundle
Browse files Browse the repository at this point in the history
If the parser returns zero roots, don't attempt to completely remove
the bundle. This may happen if, i.e., the HTTP response is 200 but has
no content. An example of this may be http://go.dev/cl/535735.

Change-Id: I81fc2b49c8ec813cca17fd1c807296bfb053d992
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/536136
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Auto-Submit: Roland Shoemaker <[email protected]>
  • Loading branch information
rolandshoemaker authored and gopherbot committed Oct 23, 2023
1 parent 1d57292 commit 4f30245
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x509roots/gen_fallback_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func main() {
log.Fatalf("failed to parse %q: %s", *certDataPath, err)
}

if len(certs) == 0 {
log.Fatal("certdata.txt appears to contain zero roots")
}

sort.Slice(certs, func(i, j int) bool {
// Sort based on the stringified subject (which may not be unique), and
// break any ties by just sorting on the raw DER (which will be unique,
Expand Down

0 comments on commit 4f30245

Please sign in to comment.