@@ -30,6 +30,7 @@ import (
30
30
"github.com/letsencrypt/boulder/ctpolicy/loglist"
31
31
"github.com/letsencrypt/boulder/goodkey"
32
32
"github.com/letsencrypt/boulder/goodkey/sagoodkey"
33
+ "github.com/letsencrypt/boulder/linter"
33
34
blog "github.com/letsencrypt/boulder/log"
34
35
"github.com/letsencrypt/boulder/metrics"
35
36
"github.com/letsencrypt/boulder/policy"
@@ -65,7 +66,7 @@ func init() {
65
66
}
66
67
67
68
func BenchmarkCheckCert (b * testing.B ) {
68
- checker := newChecker (nil , clock .New (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
69
+ checker := newChecker (nil , clock .New (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
69
70
testKey , _ := ecdsa .GenerateKey (elliptic .P256 (), rand .Reader )
70
71
expiry := time .Now ().AddDate (0 , 0 , 1 )
71
72
serial := big .NewInt (1337 )
@@ -87,7 +88,7 @@ func BenchmarkCheckCert(b *testing.B) {
87
88
}
88
89
b .ResetTimer ()
89
90
for range b .N {
90
- checker .checkCert (context .Background (), cert , nil )
91
+ checker .checkCert (context .Background (), cert )
91
92
}
92
93
}
93
94
@@ -101,7 +102,7 @@ func TestCheckWildcardCert(t *testing.T) {
101
102
102
103
testKey , _ := rsa .GenerateKey (rand .Reader , 2048 )
103
104
fc := clock .NewFake ()
104
- checker := newChecker (saDbMap , fc , pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
105
+ checker := newChecker (saDbMap , fc , pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
105
106
issued := checker .clock .Now ().Add (- time .Minute )
106
107
goodExpiry := issued .Add (testValidityDuration - time .Second )
107
108
serial := big .NewInt (1337 )
@@ -131,7 +132,7 @@ func TestCheckWildcardCert(t *testing.T) {
131
132
Issued : parsed .NotBefore ,
132
133
DER : wildcardCertDer ,
133
134
}
134
- _ , problems := checker .checkCert (context .Background (), cert , nil )
135
+ _ , problems := checker .checkCert (context .Background (), cert )
135
136
for _ , p := range problems {
136
137
t .Error (p )
137
138
}
@@ -144,7 +145,7 @@ func TestCheckCertReturnsDNSNames(t *testing.T) {
144
145
defer func () {
145
146
saCleanup ()
146
147
}()
147
- checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
148
+ checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
148
149
149
150
certPEM , err := os .ReadFile ("testdata/quite_invalid.pem" )
150
151
if err != nil {
@@ -164,7 +165,7 @@ func TestCheckCertReturnsDNSNames(t *testing.T) {
164
165
DER : block .Bytes ,
165
166
}
166
167
167
- names , problems := checker .checkCert (context .Background (), cert , nil )
168
+ names , problems := checker .checkCert (context .Background (), cert )
168
169
if ! slices .Equal (names , []string {"quite_invalid.com" , "al--so--wr--ong.com" }) {
169
170
t .Errorf ("didn't get expected DNS names. other problems: %s" , strings .Join (problems , "\n " ))
170
171
}
@@ -211,7 +212,7 @@ func TestCheckCert(t *testing.T) {
211
212
t .Run (tc .name , func (t * testing.T ) {
212
213
testKey , _ := tc .key .genKey ()
213
214
214
- checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
215
+ checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
215
216
216
217
// Create a RFC 7633 OCSP Must Staple Extension.
217
218
// OID 1.3.6.1.5.5.7.1.24
@@ -268,7 +269,7 @@ func TestCheckCert(t *testing.T) {
268
269
Expires : goodExpiry .AddDate (0 , 0 , 2 ), // Expiration doesn't match
269
270
}
270
271
271
- _ , problems := checker .checkCert (context .Background (), cert , nil )
272
+ _ , problems := checker .checkCert (context .Background (), cert )
272
273
273
274
problemsMap := map [string ]int {
274
275
"Stored digest doesn't match certificate digest" : 1 ,
@@ -295,7 +296,7 @@ func TestCheckCert(t *testing.T) {
295
296
296
297
// Same settings as above, but the stored serial number in the DB is invalid.
297
298
cert .Serial = "not valid"
298
- _ , problems = checker .checkCert (context .Background (), cert , nil )
299
+ _ , problems = checker .checkCert (context .Background (), cert )
299
300
foundInvalidSerialProblem := false
300
301
for _ , p := range problems {
301
302
if p == "Stored serial is invalid" {
@@ -320,7 +321,7 @@ func TestCheckCert(t *testing.T) {
320
321
cert .DER = goodCertDer
321
322
cert .Expires = parsed .NotAfter
322
323
cert .Issued = parsed .NotBefore
323
- _ , problems = checker .checkCert (context .Background (), cert , nil )
324
+ _ , problems = checker .checkCert (context .Background (), cert )
324
325
test .AssertEquals (t , len (problems ), 0 )
325
326
})
326
327
}
@@ -332,7 +333,7 @@ func TestGetAndProcessCerts(t *testing.T) {
332
333
fc := clock .NewFake ()
333
334
fc .Set (fc .Now ().Add (time .Hour ))
334
335
335
- checker := newChecker (saDbMap , fc , pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
336
+ checker := newChecker (saDbMap , fc , pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
336
337
sa , err := sa .NewSQLStorageAuthority (saDbMap , saDbMap , nil , 1 , 0 , fc , blog .NewMock (), metrics .NoopRegisterer )
337
338
test .AssertNotError (t , err , "Couldn't create SA to insert certificates" )
338
339
saCleanUp := test .ResetBoulderTestDatabase (t )
@@ -371,7 +372,7 @@ func TestGetAndProcessCerts(t *testing.T) {
371
372
test .AssertEquals (t , len (checker .certs ), 5 )
372
373
wg := new (sync.WaitGroup )
373
374
wg .Add (1 )
374
- checker .processCerts (context .Background (), wg , false , nil )
375
+ checker .processCerts (context .Background (), wg , false )
375
376
test .AssertEquals (t , checker .issuedReport .BadCerts , int64 (5 ))
376
377
test .AssertEquals (t , len (checker .issuedReport .Entries ), 5 )
377
378
}
@@ -426,7 +427,7 @@ func (db mismatchedCountDB) SelectOne(_ context.Context, _ interface{}, _ string
426
427
func TestGetCertsEmptyResults (t * testing.T ) {
427
428
saDbMap , err := sa .DBMapForTest (vars .DBConnSA )
428
429
test .AssertNotError (t , err , "Couldn't connect to database" )
429
- checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
430
+ checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
430
431
checker .dbMap = mismatchedCountDB {}
431
432
432
433
batchSize = 3
@@ -452,7 +453,7 @@ func (db emptyDB) SelectNullInt(_ context.Context, _ string, _ ...interface{}) (
452
453
// expected if the DB finds no certificates to match the SELECT query and
453
454
// should return an error.
454
455
func TestGetCertsNullResults (t * testing.T ) {
455
- checker := newChecker (emptyDB {}, clock .NewFake (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
456
+ checker := newChecker (emptyDB {}, clock .NewFake (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
456
457
457
458
err := checker .getCerts (context .Background ())
458
459
test .AssertError (t , err , "Should have gotten error from empty DB" )
@@ -496,7 +497,7 @@ func TestGetCertsLate(t *testing.T) {
496
497
clk := clock .NewFake ()
497
498
db := & lateDB {issuedTime : clk .Now ().Add (- time .Hour )}
498
499
checkPeriod := 24 * time .Hour
499
- checker := newChecker (db , clk , pa , kp , checkPeriod , testValidityDurations , blog .NewMock ())
500
+ checker := newChecker (db , clk , pa , kp , checkPeriod , testValidityDurations , nil , blog .NewMock ())
500
501
501
502
err := checker .getCerts (context .Background ())
502
503
test .AssertNotError (t , err , "getting certs" )
@@ -581,7 +582,7 @@ func TestIgnoredLint(t *testing.T) {
581
582
err = loglist .InitLintList ("../../test/ct-test-srv/log_list.json" )
582
583
test .AssertNotError (t , err , "failed to load ct log list" )
583
584
testKey , _ := rsa .GenerateKey (rand .Reader , 2048 )
584
- checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
585
+ checker := newChecker (saDbMap , clock .NewFake (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
585
586
serial := big .NewInt (1337 )
586
587
587
588
x509OID , err := x509 .OIDFromInts ([]uint64 {1 , 2 , 3 })
@@ -643,23 +644,26 @@ func TestIgnoredLint(t *testing.T) {
643
644
644
645
// Check the certificate with a nil ignore map. This should return the
645
646
// expected zlint problems.
646
- _ , problems := checker .checkCert (context .Background (), cert , nil )
647
+ _ , problems := checker .checkCert (context .Background (), cert )
647
648
slices .Sort (problems )
648
649
test .AssertDeepEquals (t , problems , expectedProblems )
649
650
650
651
// Check the certificate again with an ignore map that excludes the affected
651
652
// lints. This should return no problems.
652
- _ , problems = checker . checkCert ( context . Background (), cert , map [ string ] bool {
653
- "w_subject_common_name_included" : true ,
654
- "w_ext_subject_key_identifier_not_recommended_subscriber" : true ,
655
- "w_ct_sct_policy_count_unsatisfied" : true ,
656
- "e_scts_from_same_operator" : true ,
653
+ lints , err := linter . NewRegistry ([] string {
654
+ "w_subject_common_name_included" ,
655
+ "w_ext_subject_key_identifier_not_recommended_subscriber" ,
656
+ "w_ct_sct_policy_count_unsatisfied" ,
657
+ "e_scts_from_same_operator" ,
657
658
})
659
+ test .AssertNotError (t , err , "creating test lint registry" )
660
+ checker .lints = lints
661
+ _ , problems = checker .checkCert (context .Background (), cert )
658
662
test .AssertEquals (t , len (problems ), 0 )
659
663
}
660
664
661
665
func TestPrecertCorrespond (t * testing.T ) {
662
- checker := newChecker (nil , clock .New (), pa , kp , time .Hour , testValidityDurations , blog .NewMock ())
666
+ checker := newChecker (nil , clock .New (), pa , kp , time .Hour , testValidityDurations , nil , blog .NewMock ())
663
667
checker .getPrecert = func (_ context.Context , _ string ) ([]byte , error ) {
664
668
return []byte ("hello" ), nil
665
669
}
@@ -682,7 +686,7 @@ func TestPrecertCorrespond(t *testing.T) {
682
686
Issued : time .Now (),
683
687
Expires : expiry ,
684
688
}
685
- _ , problems := checker .checkCert (context .Background (), cert , nil )
689
+ _ , problems := checker .checkCert (context .Background (), cert )
686
690
if len (problems ) == 0 {
687
691
t .Errorf ("expected precert correspondence problem" )
688
692
}
0 commit comments