in go/cmd/aggregate-crls/aggregate-crls.go [238:306]
func (ae *AggregateEngine) aggregateCRLWorker(ctx context.Context, wg *sync.WaitGroup,
workChan <-chan types.IssuerCrlUrlPaths) {
defer wg.Done()
for tuple := range workChan {
anyCrlFailed := false
cert, err := ae.issuers.GetCertificateForIssuer(tuple.Issuer)
if err != nil {
glog.Fatalf("[%s] Could not find certificate for issuer: %s", tuple.Issuer.ID(), err)
}
serialCount := 0
serials := make([]types.SerialAndReason, 0, 128*1024)
for _, crlUrlPath := range tuple.CrlUrlPaths {
select {
case <-ctx.Done():
return
default:
if crlUrlPath.Path == "" {
anyCrlFailed = true
// DownloadAndVerifyFileSync already notified the auditor
glog.Errorf("[%+v] Failed to download: %s", crlUrlPath, err)
continue
}
crl, sha256sum, err := loadAndCheckSignatureOfCRL(crlUrlPath.Path, cert)
if err != nil {
anyCrlFailed = true
ae.auditor.FailedVerifyPath(&tuple.Issuer, &crlUrlPath.Url, crlUrlPath.Path, err)
glog.Errorf("[%+v] Failed to verify: %s", crlUrlPath, err)
continue
}
revokedSerials, err := processCRL(crl)
if err != nil {
anyCrlFailed = true
ae.auditor.FailedProcessLocal(&tuple.Issuer, &crlUrlPath.Url, crlUrlPath.Path, err)
glog.Errorf("[%+v] Failed to process: %s", crlUrlPath, err)
continue
}
revokedCount := len(revokedSerials)
if revokedCount == 0 {
ae.auditor.NoRevocations(&tuple.Issuer, &crlUrlPath.Url, crlUrlPath.Path)
continue
}
age := time.Since(crl.TBSCertList.ThisUpdate)
ae.auditor.ValidAndProcessed(&tuple.Issuer, &crlUrlPath.Url, crlUrlPath.Path, revokedCount, age, sha256sum)
serials = append(serials, revokedSerials...)
serialCount += revokedCount
}
}
if anyCrlFailed == false {
if err := ae.StoreRevokedCertificateList(ctx, tuple.Issuer, serials); err != nil {
glog.Fatalf("[%s] Could not save revoked certificates file: %s", tuple.Issuer.ID(), err)
}
glog.Infof("[%s] %d total revoked serials for %s (len=%d, cap=%d)", tuple.Issuer.ID(),
serialCount, tuple.IssuerDN, len(serials), cap(serials))
} else {
glog.Infof("May not have all revoked certificates for issuer %s", tuple.Issuer.ID())
}
}
}