Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 00:15 UTC
caddypki: Minor tweak, don't use context pointer
Matthew Holt committed
Dec 13, 2021 at 16:13 UTC
a1c41210d34c629c3b5cdbdca74c540fde752aad
3 files changed
+5
-9
modules/caddypki/acmeserver/acmeserver.go
+1
-1
@@ -102,7 +102,7 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
102
return err
103
}
104
pkiApp := appModule.(*caddypki.PKI)
105
- ca, err := pkiApp.GetCA(ash.CA, &ctx)
105
+ ca, err := pkiApp.GetCA(ctx, ash.CA)
106
if err != nil {
107
return err
108
}
modules/caddypki/pki.go
+3
-7
@@ -121,9 +121,8 @@ func (p *PKI) Stop() error {
121
122
// GetCA retrieves a CA by ID. If the ID is the default
123
// CA ID, and it hasn't been provisioned yet, it will
124
-// be provisioned. The context must be passed if this
125
-// is called from a module's Provision().
126
-func (p *PKI) GetCA(id string, ctx *caddy.Context) (*CA, error) {
124
+// be provisioned.
125
+func (p *PKI) GetCA(ctx caddy.Context, id string) (*CA, error) {
126
ca, ok := p.CAs[id]
127
if !ok {
128
// 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) {
131
}
132
133
// for the default CA ID, provision it, because we want it to "just work"
135
- if ctx == nil {
136
- return nil, fmt.Errorf("cannot provision default CA without the context")
137
- }
138
- err := p.ProvisionDefaultCA(*ctx)
134
+ err := p.ProvisionDefaultCA(ctx)
135
if err != nil {
136
return nil, fmt.Errorf("failed to provision default CA: %s", err)
137
}
modules/caddytls/internalissuer.go
+1
-1
@@ -78,7 +78,7 @@ func (iss *InternalIssuer) Provision(ctx caddy.Context) error {
78
return err
79
}
80
pkiApp := appModule.(*caddypki.PKI)
81
- ca, err := pkiApp.GetCA(iss.CA, &ctx)
81
+ ca, err := pkiApp.GetCA(ctx, iss.CA)
82
if err != nil {
83
return err
84
}