Inject the acme database in the context

This commit is contained in:
Mariano Cano 2022-04-27 12:13:16 -07:00
parent bd412c9f42
commit 8bd4e1d73e

View file

@ -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
}