in go/cmd/aggregate-crls/aggregate-crls.go [413:497]
func main() {
ctconfig.Init()
ctx, cancel := context.WithCancel(context.Background())
defer glog.Flush()
checkPathArg(*revokedpath, "revokedpath", ctconfig)
checkPathArg(*crlpath, "crlpath", ctconfig)
checkPathArg(*enrolledpath, "enrolledpath", ctconfig)
checkPathArg(*auditpath, "auditpath", ctconfig)
if err := os.MkdirAll(*revokedpath, permModeDir); err != nil {
glog.Fatalf("Unable to make the revokedpath directory: %s", err)
}
if err := os.MkdirAll(*crlpath, permModeDir); err != nil {
glog.Fatalf("Unable to make the CRL directory: %s", err)
}
engine.PrepareTelemetry("aggregate-crls", ctconfig)
mozIssuers := rootprogram.NewMozillaIssuers()
if *inccadb != "<path>" {
mozIssuers.DiskPath = *inccadb
}
err := mozIssuers.Load()
if err != nil {
glog.Fatalf("Unable to load the Mozilla issuers: %s", err)
return
}
glog.Infof("Issuer file age: %s", mozIssuers.DatasetAge().Round(time.Second))
// Exit signal, used by signals from the OS
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM, os.Interrupt)
defer signal.Stop(sigChan)
go func() {
<-sigChan
glog.Infof("Signal caught, stopping threads at next opportunity.")
cancel()
signal.Stop(sigChan)
}()
auditor := NewCrlAuditor(mozIssuers)
ae := AggregateEngine{
rootPath: *revokedpath,
issuers: mozIssuers,
auditor: auditor,
}
issuerCrlMap := make(types.IssuerCrlMap)
for issuer, crls := range mozIssuers.CrlMap {
issuerCrlMap[issuer] = make(map[string]bool)
for crl, _ := range crls {
issuerCrlMap[issuer][crl] = true
}
}
crlPaths, count := ae.downloadCRLs(ctx, issuerCrlMap)
if ctx.Err() != nil {
return
}
ae.aggregateCRLs(ctx, count, crlPaths)
if err := mozIssuers.SaveIssuersList(*enrolledpath); err != nil {
glog.Fatalf("Unable to save the crlite-informed intermediate issuers to %s: %s", *enrolledpath, err)
}
glog.Infof("Saved crlite-informed intermediate issuers to %s", *enrolledpath)
fd, err := os.Create(*auditpath)
if err != nil {
glog.Warningf("Could not open audit report path %s: %v", *auditpath, err)
return
}
if err = auditor.WriteReport(fd); err != nil {
glog.Warningf("Could not write audit report %s: %v", *auditpath, err)
}
err = fd.Close()
if err != nil {
glog.Warningf("Could not close audit report %s: %v", *auditpath, err)
}
}