You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check that there is a valid CRL in the DB right now. If it doesnt exist
667
+
// or is expired, generated one now
668
+
crlDB, ok:=a.db.(db.CertificateRevocationListDB)
669
+
if!ok {
670
+
returnerrors.Errorf("CRL Generation requested, but database does not support CRL generation")
671
+
}
672
+
673
+
crlInfo, err:=crlDB.GetCRL()
674
+
iferr!=nil {
675
+
returnerrors.Wrap(err, "could not retrieve CRL from database")
676
+
}
677
+
678
+
ifcrlInfo==nil {
679
+
log.Println("No CRL exists in the DB, generating one now")
680
+
err=a.GenerateCertificateRevocationList()
681
+
iferr!=nil {
682
+
returnerrors.Wrap(err, "could not generate a CRL")
683
+
}
684
+
}
685
+
686
+
ifcrlInfo.ExpiresAt.Before(time.Now().UTC()) {
687
+
log.Printf("Existing CRL has expired (at %v), generating a new one", crlInfo.ExpiresAt)
688
+
err=a.GenerateCertificateRevocationList()
689
+
iferr!=nil {
690
+
returnerrors.Wrap(err, "could not generate a CRL")
691
+
}
692
+
}
693
+
694
+
log.Printf("CRL will be auto-generated every %v", a.config.CRL.CacheDuration)
695
+
tickerDuration:=a.config.CRL.CacheDuration.Duration-time.Minute// generate the new CRL 1 minute before it expires
696
+
iftickerDuration<=0 {
697
+
log.Printf("WARNING: Addition of jitter to CRL generation time %v creates a negative duration (%v). Using 1 minute cacheDuration", a.config.CRL.CacheDuration, tickerDuration)
698
+
tickerDuration=time.Minute
699
+
}
700
+
crlTicker:=time.NewTicker(tickerDuration)
701
+
702
+
gofunc() {
703
+
for {
704
+
select {
705
+
case<-crlTicker.C:
706
+
log.Println("Regenerating CRL")
707
+
err:=a.GenerateCertificateRevocationList()
708
+
iferr!=nil {
709
+
// TODO: log or panic here?
710
+
panic(errors.Wrap(err, "authority.crlGenerator encountered an error"))
returnnil, errs.Wrap(http.StatusInternalServerError, errors.Errorf("Certificate Revocation Lists are not enabled"), "authority.GetCertificateRevocationList")
530
+
}
518
531
519
-
// check for an existing CRL in the database, and return that if its valid
520
-
crlInfo, err:=a.db.GetCRL()
532
+
crlDB, ok:=a.db.(db.CertificateRevocationListDB)
533
+
if!ok {
534
+
returnnil, errs.Wrap(http.StatusInternalServerError, errors.Errorf("Database does not support Certificate Revocation Lists"), "authority.GetCertificateRevocationList")
0 commit comments