@@ -18,6 +18,7 @@ import (
18
18
"bufio"
19
19
"bytes"
20
20
"context"
21
+ "crypto/sha256"
21
22
"crypto/x509"
22
23
"encoding/base64"
23
24
"encoding/hex"
@@ -507,7 +508,7 @@ func TestAddChain(t *testing.T) {
507
508
t .Errorf ("http.Post(%s)=(%d,nil); want (%d,nil)" , rfc6962 .AddChainPath , got , want )
508
509
}
509
510
if test .want == http .StatusOK {
510
- unseqEntry , _ := parseChain (t , false , test .chain , log .chainValidationOpts .trustedRoots .RawCertificates ()[0 ])
511
+ unseqEntry , wantIssChain := parseChain (t , false , test .chain , log .chainValidationOpts .trustedRoots .RawCertificates ()[0 ])
511
512
512
513
var gotRsp rfc6962.AddChainResponse
513
514
if err := json .NewDecoder (resp .Body ).Decode (& gotRsp ); err != nil {
@@ -559,7 +560,20 @@ func TestAddChain(t *testing.T) {
559
560
if diff := cmp .Diff (wantEntry , gotEntry ); diff != "" {
560
561
t .Errorf ("Logged entry mismatch (-want +got):\n %s" , diff )
561
562
}
562
- // TODO(phbnf): check the issuer chain fingerprint
563
+
564
+ // Check that the issuers have been populated correctly.
565
+ for _ , wantIss := range wantIssChain [1 :] {
566
+ key := sha256 .Sum256 (wantIss .Raw )
567
+ issPath := path .Join (dir , issDir , hex .EncodeToString (key [:]))
568
+ gotIss , err := os .ReadFile (issPath )
569
+ if err != nil {
570
+ t .Errorf ("Failed to read issuer at %q: %v" , issPath , err )
571
+ }
572
+ if ! bytes .Equal (gotIss , wantIss .Raw ) {
573
+ t .Errorf ("Issuer mismatch: got %s, want %s" , gotIss , wantIss .Raw )
574
+ }
575
+ }
576
+
563
577
// TODO(phbnf): check inclusion proof
564
578
// TODO(phbnf): add a test with a backend write failure
565
579
}
@@ -633,7 +647,7 @@ func TestAddPreChain(t *testing.T) {
633
647
t .Errorf ("http.Post(%s)=(%d,nil); want (%d,nil)" , rfc6962 .AddPreChainPath , got , want )
634
648
}
635
649
if test .want == http .StatusOK {
636
- unseqEntry , _ := parseChain (t , true , test .chain , log .chainValidationOpts .trustedRoots .RawCertificates ()[0 ])
650
+ unseqEntry , wantIssChain := parseChain (t , true , test .chain , log .chainValidationOpts .trustedRoots .RawCertificates ()[0 ])
637
651
638
652
var gotRsp rfc6962.AddChainResponse
639
653
if err := json .NewDecoder (resp .Body ).Decode (& gotRsp ); err != nil {
@@ -685,7 +699,20 @@ func TestAddPreChain(t *testing.T) {
685
699
if diff := cmp .Diff (wantEntry , gotEntry ); diff != "" {
686
700
t .Errorf ("Logged entry mismatch (-want +got):\n %s" , diff )
687
701
}
688
- // TODO(phbnf): check the issuer chain fingerprint
702
+
703
+ // Check that the issuers have been populated correctly.
704
+ for _ , wantIss := range wantIssChain [1 :] {
705
+ key := sha256 .Sum256 (wantIss .Raw )
706
+ issPath := path .Join (dir , issDir , hex .EncodeToString (key [:]))
707
+ gotIss , err := os .ReadFile (issPath )
708
+ if err != nil {
709
+ t .Errorf ("Failed to read issuer at %q: %v" , issPath , err )
710
+ }
711
+ if ! bytes .Equal (gotIss , wantIss .Raw ) {
712
+ t .Errorf ("Issuer mismatch: got %s, want %s" , gotIss , wantIss .Raw )
713
+ }
714
+ }
715
+
689
716
// TODO(phbnf): check inclusion proof
690
717
// TODO(phboneff): add a test with a backend write failure
691
718
}
0 commit comments