Explorar o código

Warn when ACME provisioner is configured without database

When an ACME provisioner is configured but the database is not set up,
ACME endpoints silently fail with 404 errors. This change adds a warning
at startup to inform users that ACME functionality will not be available
without a database configuration.

Fixes #2102
Carl Tashian hai 11 meses
pai
achega
21021ffe18
Modificáronse 2 ficheiros con 13 adicións e 0 borrados
  1. 10 0
      authority/authority.go
  2. 3 0
      ca/ca.go

+ 10 - 0
authority/authority.go

@@ -988,6 +988,16 @@ func (a *Authority) GetSCEP() *scep.Authority {
 	return a.scepAuthority
 	return a.scepAuthority
 }
 }
 
 
+// HasACMEProvisioner returns true if at least one ACME provisioner is configured.
+func (a *Authority) HasACMEProvisioner() bool {
+	for _, p := range a.config.AuthorityConfig.Provisioners {
+		if p.GetType() == provisioner.TypeACME {
+			return true
+		}
+	}
+	return false
+}
+
 func (a *Authority) startCRLGenerator() error {
 func (a *Authority) startCRLGenerator() error {
 	if !a.config.CRL.IsEnabled() {
 	if !a.config.CRL.IsEnabled() {
 		return nil
 		return nil

+ 3 - 0
ca/ca.go

@@ -262,6 +262,9 @@ func (ca *CA) Init(cfg *config.Config) (*CA, error) {
 	// ACME Router is only available if we have a database.
 	// ACME Router is only available if we have a database.
 	var acmeDB acme.DB
 	var acmeDB acme.DB
 	var acmeLinker acme.Linker
 	var acmeLinker acme.Linker
+	if cfg.DB == nil && auth.HasACMEProvisioner() {
+		log.Println("WARNING: No database is configured. ACME provisioners are disabled.")
+	}
 	if cfg.DB != nil {
 	if cfg.DB != nil {
 		acmeDB, err = acmeNoSQL.New(auth.GetDatabase().(nosql.DB))
 		acmeDB, err = acmeNoSQL.New(auth.GetDatabase().(nosql.DB))
 		if err != nil {
 		if err != nil {