summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2021-12-13 16:13:29 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2021-12-13 16:13:38 -0700
commita1c41210d34c629c3b5cdbdca74c540fde752aad (patch)
tree3889632b4fe919878b78b4b59f9c35635e239641
parentecac03cdcb6cceae743aac16faca7f32e5da1607 (diff)
caddypki: Minor tweak, don't use context pointer
-rw-r--r--modules/caddypki/acmeserver/acmeserver.go2
-rw-r--r--modules/caddypki/pki.go10
-rw-r--r--modules/caddytls/internalissuer.go2
3 files changed, 5 insertions, 9 deletions
diff --git a/modules/caddypki/acmeserver/acmeserver.go b/modules/caddypki/acmeserver/acmeserver.go
index 388aa52..ff021b4 100644
--- a/modules/caddypki/acmeserver/acmeserver.go
+++ b/modules/caddypki/acmeserver/acmeserver.go
@@ -102,7 +102,7 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
return err
}
pkiApp := appModule.(*caddypki.PKI)
- ca, err := pkiApp.GetCA(ash.CA, &ctx)
+ ca, err := pkiApp.GetCA(ctx, ash.CA)
if err != nil {
return err
}
diff --git a/modules/caddypki/pki.go b/modules/caddypki/pki.go
index f391fda..c19bd0f 100644
--- a/modules/caddypki/pki.go
+++ b/modules/caddypki/pki.go
@@ -121,9 +121,8 @@ func (p *PKI) Stop() error {
// GetCA retrieves a CA by ID. If the ID is the default
// CA ID, and it hasn't been provisioned yet, it will
-// be provisioned. The context must be passed if this
-// is called from a module's Provision().
-func (p *PKI) GetCA(id string, ctx *caddy.Context) (*CA, error) {
+// be provisioned.
+func (p *PKI) GetCA(ctx caddy.Context, id string) (*CA, error) {
ca, ok := p.CAs[id]
if !ok {
// for anything other than the default CA ID, error out if it wasn't configured
@@ -132,10 +131,7 @@ func (p *PKI) GetCA(id string, ctx *caddy.Context) (*CA, error) {
}
// for the default CA ID, provision it, because we want it to "just work"
- if ctx == nil {
- return nil, fmt.Errorf("cannot provision default CA without the context")
- }
- err := p.ProvisionDefaultCA(*ctx)
+ err := p.ProvisionDefaultCA(ctx)
if err != nil {
return nil, fmt.Errorf("failed to provision default CA: %s", err)
}
diff --git a/modules/caddytls/internalissuer.go b/modules/caddytls/internalissuer.go
index d9b6117..5de3af5 100644
--- a/modules/caddytls/internalissuer.go
+++ b/modules/caddytls/internalissuer.go
@@ -78,7 +78,7 @@ func (iss *InternalIssuer) Provision(ctx caddy.Context) error {
return err
}
pkiApp := appModule.(*caddypki.PKI)
- ca, err := pkiApp.GetCA(iss.CA, &ctx)
+ ca, err := pkiApp.GetCA(ctx, iss.CA)
if err != nil {
return err
}