@@ -79,11 +79,6 @@ func (c CCADBConf) MakeProber(collectors map[string]prometheus.Collector) (probe
7979 }
8080 }
8181
82- crlsSuccess , ok := collectors ["ccadb_crls_success" ]
83- if ! ok {
84- return nil , fmt .Errorf ("CCADB prober did not receive metric \" ccadb_crls_success\" " )
85- }
86-
8782 crlRegexp := `^http://[a-z0-9-]+\.c\.lencr\.org/\d+\.crl$`
8883 if c .CRLRegexp != "" {
8984 crlRegexp = c .CRLRegexp
@@ -100,8 +95,6 @@ func (c CCADBConf) MakeProber(collectors map[string]prometheus.Collector) (probe
10095 caOwner : caOwner ,
10196 crlAgeLimit : ageLimitDuration ,
10297 crlRegexp : re ,
103-
104- crlsSuccess : crlsSuccess ,
10598 }, nil
10699}
107100
@@ -110,14 +103,7 @@ func (c CCADBConf) MakeProber(collectors map[string]prometheus.Collector) (probe
110103// objects, indexed by the name of the Prometheus metric. If no objects were
111104// constructed, nil is returned.
112105func (c CCADBConf ) Instrument () map [string ]prometheus.Collector {
113- crlsSuccess := prometheus .Collector (prometheus .NewCounter (
114- prometheus.CounterOpts {
115- Name : "ccadb_crls_success" ,
116- Help : "Fetching and linting all CRLs succeeded." ,
117- }))
118- return map [string ]prometheus.Collector {
119- "ccadb_crls_success" : crlsSuccess ,
120- }
106+ return nil
121107}
122108
123109func getIDP (crl * x509.RevocationList ) (string , error ) {
@@ -147,8 +133,6 @@ type CCADBProber struct {
147133 caOwner string
148134 crlAgeLimit time.Duration
149135 crlRegexp * regexp.Regexp
150-
151- crlsSuccess prometheus.Collector
152136}
153137
154138func (c CCADBProber ) Kind () string {
@@ -253,7 +237,7 @@ func getCSV(ctx context.Context, url string) ([]string, *csv.Reader, error) {
253237 reader := csv .NewReader (bytes .NewReader (body ))
254238 header , err := reader .Read ()
255239 if err != nil {
256- return nil , nil , err
240+ return nil , nil , fmt . Errorf ( "%q: %w" , url , err )
257241 }
258242
259243 return header , reader , nil
@@ -282,6 +266,9 @@ func (c CCADBProber) getDecadeIntermediates(ctx context.Context, decade int) (ma
282266 }
283267
284268 pemIndex := slices .Index (header , "X.509 Certificate (PEM)" )
269+ if pemIndex == - 1 {
270+ return nil , fmt .Errorf ("no column named \" X.509 Certificate (PEM)\" in %s" , url )
271+ }
285272
286273 ret := make (map [string ]* x509.Certificate )
287274 for {
@@ -290,7 +277,7 @@ func (c CCADBProber) getDecadeIntermediates(ctx context.Context, decade int) (ma
290277 break
291278 }
292279 if err != nil {
293- return nil , err
280+ return nil , fmt . Errorf ( "%q: %w" , url , err )
294281 }
295282
296283 if len (record ) < pemIndex {
@@ -322,23 +309,35 @@ func (c CCADBProber) getCRLURLs(ctx context.Context, issuers map[string]*x509.Ce
322309 return nil , err
323310 }
324311
325- ownerIndex := slices .Index (header , "CA Owner" )
326- crlIndex := slices .Index (header , "JSON Array of Partitioned CRLs" )
327- skidIndex := slices .Index (header , "Subject Key Identifier" )
328- certificateNameIndex := slices .Index (header , "Certificate Name" )
312+ const (
313+ owner = "CA Owner"
314+ crl = "JSON Array of Partitioned CRLs"
315+ skid = "Subject Key Identifier"
316+ certificateName = "Certificate Name"
317+ )
318+
319+ columns := map [string ]int {}
320+ for _ , headerName := range []string {owner , crl , skid , certificateName } {
321+ index := slices .Index (header , headerName )
322+ if index == - 1 {
323+ return nil , fmt .Errorf ("no column named %q in %s" , headerName , c .allCertificatesCSVURL )
324+ }
325+ columns [headerName ] = index
326+ }
327+
329328 allCRLs := make (map [string ][]string )
330329 for {
331330 record , err := reader .Read ()
332331 if err == io .EOF {
333332 break
334333 }
335334 if err != nil {
336- return nil , err
335+ return nil , fmt . Errorf ( "%q: %w" , c . allCertificatesCSVURL , err )
337336 }
338- if record [ownerIndex ] != c .caOwner {
337+ if record [columns [ owner ] ] != c .caOwner {
339338 continue
340339 }
341- crlJSON := record [crlIndex ]
340+ crlJSON := record [columns [ crl ] ]
342341 if crlJSON == "" {
343342 continue
344343 }
@@ -347,8 +346,8 @@ func (c CCADBProber) getCRLURLs(ctx context.Context, issuers map[string]*x509.Ce
347346 if err != nil {
348347 return nil , err
349348 }
350- certificateName := record [certificateNameIndex ]
351- skidBase64 := record [skidIndex ]
349+ certificateName := record [columns [ certificateName ] ]
350+ skidBase64 := record [columns [ skid ] ]
352351 skid , err := base64 .StdEncoding .DecodeString (skidBase64 )
353352 if err != nil {
354353 return nil , err
0 commit comments