This gradual step towards removing/inlining subjectsEqual can happen after Go 1.27.0 is released and the bundle starts being generated with it. Change-Id: Ib315bae69c45922c3f0aac5d2c0155fb5d94229f Reviewed-on: https://go-review.googlesource.com/c/crypto/+/775782 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
33 lines
942 B
Go
33 lines
942 B
Go
// Copyright 2025 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package bundle
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"crypto/x509"
|
|
"encoding/hex"
|
|
"testing"
|
|
)
|
|
|
|
func TestBundle(t *testing.T) {
|
|
for i, unparsed := range unparsedCertificates {
|
|
cert, err := x509.ParseCertificate(rawCerts[unparsed.certStartOff : unparsed.certStartOff+unparsed.certLength])
|
|
if err != nil {
|
|
t.Errorf("ParseCertificate(unparsedCertificates[%v]) unexpected error: %v", i, err)
|
|
continue
|
|
}
|
|
|
|
if !subjectsEqual(unparsed.cn, cert.Subject.String()) {
|
|
t.Errorf("unparsedCertificates[%v].cn = %q; want = %q", i, unparsed.cn, cert.Subject.String())
|
|
}
|
|
|
|
sum := sha256.Sum256(cert.Raw)
|
|
sumHex := hex.EncodeToString(sum[:])
|
|
if sumHex != unparsed.sha256Hash {
|
|
t.Errorf("unparsedCertificates[%v].sha256Hash = %q; want = %q", i, unparsed.sha256Hash, sumHex)
|
|
}
|
|
}
|
|
}
|