Просмотр исходного кода

Inject the acme database in the context

Mariano Cano 4 лет назад
Родитель
Сommit
8bd4e1d73e
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      ca/ca.go

+ 5 - 2
ca/ca.go

@@ -282,7 +282,7 @@ func (ca *CA) Init(cfg *config.Config) (*CA, error) {
 	}
 
 	// Create context with all the necessary values.
-	baseContext := buildContext(auth)
+	baseContext := buildContext(auth, acmeDB)
 
 	ca.srv = server.New(cfg.Address, handler, tlsConfig)
 	ca.srv.BaseContext = func(net.Listener) context.Context {
@@ -306,7 +306,7 @@ func (ca *CA) Init(cfg *config.Config) (*CA, error) {
 }
 
 // buildContext builds the server base context.
-func buildContext(a *authority.Authority) context.Context {
+func buildContext(a *authority.Authority, acmeDB acme.DB) context.Context {
 	ctx := authority.NewContext(context.Background(), a)
 	if authDB := a.GetDatabase(); authDB != nil {
 		ctx = db.NewContext(ctx, authDB)
@@ -314,6 +314,9 @@ func buildContext(a *authority.Authority) context.Context {
 	if adminDB := a.GetAdminDatabase(); adminDB != nil {
 		ctx = admin.NewContext(ctx, adminDB)
 	}
+	if acmeDB != nil {
+		ctx = acme.NewContext(ctx, acmeDB)
+	}
 	return ctx
 }