RebuildCertMagic rebuilds the policy's CertMagic configuration from the policy's already-populated fields (Issuers, Managers, storage, etc.) and replaces the internal CertMagic instance. This is a lightweight alternative to calling Provision because it does not re-provision modules or re-run module
(tlsApp *TLS)
| 395 | // app). RebuildCertMagic should only be called when the policy's required |
| 396 | // fields are already populated. |
| 397 | func (ap *AutomationPolicy) RebuildCertMagic(tlsApp *TLS) error { |
| 398 | cfg, err := ap.makeCertMagicConfig(tlsApp, ap.Issuers, ap.storage) |
| 399 | if err != nil { |
| 400 | return err |
| 401 | } |
| 402 | certCacheMu.RLock() |
| 403 | ap.magic = certmagic.New(certCache, cfg) |
| 404 | certCacheMu.RUnlock() |
| 405 | |
| 406 | // sometimes issuers may need the parent certmagic.Config in |
| 407 | // order to function properly (for example, ACMEIssuer needs |
| 408 | // access to the correct storage and cache so it can solve |
| 409 | // ACME challenges -- it's an annoying, inelegant circular |
| 410 | // dependency that I don't know how to resolve nicely!) |
| 411 | for _, issuer := range ap.magic.Issuers { |
| 412 | if annoying, ok := issuer.(ConfigSetter); ok { |
| 413 | annoying.SetConfig(ap.magic) |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | return nil |
| 418 | } |
| 419 | |
| 420 | // Subjects returns the list of subjects with all placeholders replaced. |
| 421 | func (ap *AutomationPolicy) Subjects() []string { |
no test coverage detected