in go/cmd/aggregate-crls/aggregate-crls.go [78:127]
func (ae *AggregateEngine) crlFetchWorkerProcessOne(ctx context.Context, crlUrl url.URL, issuer types.Issuer) (string, error) {
err := os.MkdirAll(filepath.Join(*crlpath, issuer.ID()), permModeDir)
if err != nil {
glog.Warningf("Couldn't make directory: %s", err)
return "", err
}
filename := makeFilenameFromUrl(crlUrl)
finalPath := filepath.Join(*crlpath, issuer.ID(), filename)
cert, err := ae.issuers.GetCertificateForIssuer(issuer)
if err != nil {
glog.Fatalf("[%s] Could not find certificate for issuer: %s", issuer.ID(), err)
}
verifyFunc := &CrlVerifier{
expectedIssuerCert: cert,
}
fileOnDiskIsAcceptable, dlErr := downloader.DownloadAndVerifyFileSync(ctx, verifyFunc, ae.auditor,
&issuer, crlUrl, finalPath, 3, 300*time.Second)
if !fileOnDiskIsAcceptable {
glog.Errorf("[%s] Could not download, and no local file, will not be populating the "+
"revocations: %s", crlUrl.String(), dlErr)
return "", dlErr
}
if dlErr != nil {
glog.Errorf("[%s] Problem downloading: %s", crlUrl.String(), dlErr)
}
// Ensure the final path is acceptable
localSize, localDate, err := downloader.GetSizeAndDateOfFile(finalPath)
if err != nil {
glog.Errorf("[%s] Unexpected error on local file, will not be populating the "+
"revocations: %s", crlUrl.String(), err)
return "", err
}
age := time.Now().Sub(localDate)
if age > allowableAgeOfLocalCRL {
ae.auditor.Old(&issuer, &crlUrl, age)
glog.Warningf("[%s] CRL appears not very fresh, but proceeding with expiration check. Age: %s", crlUrl.String(), age)
}
glog.Infof("[%s] Updated CRL %s (path=%s) (sz=%d) (age=%s)", issuer.ID(), crlUrl.String(),
finalPath, localSize, age)
return finalPath, nil
}