MCPcopy
hub / github.com/caddyserver/caddy / Provision

Method Provision

modules/caddytls/acmeissuer.go:129–252  ·  view source on GitHub ↗

Provision sets up iss.

(ctx caddy.Context)

Source from the content-addressed store, hash-verified

127
128// Provision sets up iss.
129func (iss *ACMEIssuer) Provision(ctx caddy.Context) error {
130 iss.logger = ctx.Logger()
131
132 repl := caddy.NewReplacer()
133
134 // expand email address, if non-empty
135 if iss.Email != "" {
136 email, err := repl.ReplaceOrErr(iss.Email, true, true)
137 if err != nil {
138 return fmt.Errorf("expanding email address '%s': %v", iss.Email, err)
139 }
140 iss.Email = email
141 }
142
143 // expand CA endpoint, if non-empty
144 if iss.CA != "" {
145 ca, err := repl.ReplaceOrErr(iss.CA, true, true)
146 if err != nil {
147 return fmt.Errorf("expanding CA endpoint '%s': %v", iss.CA, err)
148 }
149 iss.CA = ca
150 }
151
152 // expand TestCA endpoint, if non-empty
153 if iss.TestCA != "" {
154 testca, err := repl.ReplaceOrErr(iss.TestCA, true, true)
155 if err != nil {
156 return fmt.Errorf("expanding TestCA endpoint '%s': %v", iss.TestCA, err)
157 }
158 iss.TestCA = testca
159 }
160
161 // expand EAB credentials, if non-empty
162 if iss.ExternalAccount != nil {
163 if iss.ExternalAccount.KeyID != "" {
164 keyID, err := repl.ReplaceOrErr(iss.ExternalAccount.KeyID, true, true)
165 if err != nil {
166 return fmt.Errorf("expanding EAB key ID '%s': %v", iss.ExternalAccount.KeyID, err)
167 }
168 iss.ExternalAccount.KeyID = keyID
169 }
170 if iss.ExternalAccount.MACKey != "" {
171 macKey, err := repl.ReplaceOrErr(iss.ExternalAccount.MACKey, true, true)
172 if err != nil {
173 return fmt.Errorf("expanding EAB MAC key (redacted): %v", err)
174 }
175 iss.ExternalAccount.MACKey = macKey
176 }
177 }
178
179 // expand account key, if non-empty
180 if iss.AccountKey != "" {
181 accountKey, err := repl.ReplaceOrErr(iss.AccountKey, true, true)
182 if err != nil {
183 return fmt.Errorf("expanding account key PEM '%s': %v", iss.AccountKey, err)
184 }
185 iss.AccountKey = accountKey
186 }

Callers 1

Calls 7

ReplaceOrErrMethod · 0.95
makeIssuerTemplateMethod · 0.95
LoadModuleMethod · 0.80
AppIfConfiguredMethod · 0.80
DurationMethod · 0.80
ReadFileMethod · 0.80
LoggerMethod · 0.45

Tested by 1