Skip to content

Commit 4fff1f3

Browse files
authored
Detect duplicate CRL versions (#167)
In rare cases, two versions of the same CRL shard may be identical. Handle that case appropriately.
1 parent a00da54 commit 4fff1f3

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

checker/earlyremoval/check.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package earlyremoval
22

33
import (
4+
"bytes"
45
"context"
56
"crypto/x509"
67
"log"
@@ -53,6 +54,19 @@ func sample[T any](input []T, max int) []T {
5354

5455
// Check for early removal. If maxFetch is greater than 0, only check that many serials
5556
func Check(ctx context.Context, fetcher Fetcher, maxFetch int, prev *x509.RevocationList, crl *x509.RevocationList) ([]EarlyRemoval, error) {
57+
// In rare cases, a duplicate CRL version may be uploaded. This causes a flake,
58+
// because checker.Diff() expects CRLs to be increasing in version number. It is
59+
// valid for duplicate versions to be uploaded, as long as they're bit-for-bit
60+
// identical.
61+
//
62+
// We'll skip this check if the CRLs are identical. We would have checked the
63+
// previous CRL version already, so we don't have any work to do on the newer
64+
// version.
65+
if len(crl.Raw) > 0 && bytes.Equal(prev.Raw, crl.Raw) {
66+
log.Printf("previous and current CRL (number %d) are identical; skipping early removal check", crl.Number)
67+
return nil, nil
68+
}
69+
5670
diff, err := checker.Diff(prev, crl)
5771
if err != nil {
5872
return nil, err

checker/earlyremoval/check_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ func TestCheck(t *testing.T) {
3232
}{
3333
{name: "no removals", prev: &testdata.CRL1, crl: &testdata.CRL2},
3434
{name: "remove 1", prev: &testdata.CRL2, crl: &testdata.CRL3},
35+
{
36+
name: "bit-for-bit identical CRL",
37+
prev: &x509.RevocationList{Raw: []byte{0x30, 0x01, 0x00}, Number: big.NewInt(2)},
38+
crl: &x509.RevocationList{Raw: []byte{0x30, 0x01, 0x00}, Number: big.NewInt(2)},
39+
},
3540
{
3641
name: "early removal",
3742
prev: &testdata.CRL3,

0 commit comments

Comments
 (0)