Skip to content

Commit ed73243

Browse files
committed
Export interface for GetRenewalInfo
We can't assume the ARI-supporting issuer types are exactly *ACMEIssuer; they may be implemented by third party packages (such as caddytls.ACMEIssuer).
1 parent bd400cc commit ed73243

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

acmeclient.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func (iss *ACMEIssuer) newBasicACMEClient() (*acmez.Client, error) {
235235
}, nil
236236
}
237237

238-
func (iss *ACMEIssuer) getRenewalInfo(ctx context.Context, cert Certificate) (acme.RenewalInfo, error) {
238+
// GetRenewalInfo gets the ACME Renewal Information (ARI) for the certificate.
239+
func (iss *ACMEIssuer) GetRenewalInfo(ctx context.Context, cert Certificate) (acme.RenewalInfo, error) {
239240
acmeClient, err := iss.newBasicACMEClient()
240241
if err != nil {
241242
return acme.RenewalInfo{}, err
@@ -312,6 +313,15 @@ func buildUAString() string {
312313
return ua
313314
}
314315

316+
// RenewalInfoGetter is a type that can get ACME Renewal Information (ARI).
317+
// Users of this package that wrap the ACMEIssuer or use any other issuer
318+
// that supports ARI will need to implement this so that CertMagic can
319+
// update ARI which happens outside the normal issuance flow and is thus
320+
// not required by the Issuer interface (a type assertion is performed).
321+
type RenewalInfoGetter interface {
322+
GetRenewalInfo(context.Context, Certificate) (acme.RenewalInfo, error)
323+
}
324+
315325
// These internal rate limits are designed to prevent accidentally
316326
// firehosing a CA's ACME endpoints. They are not intended to
317327
// replace or replicate the CA's actual rate limits.

maintain.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ func (cfg *Config) updateARI(ctx context.Context, cert Certificate, logger *zap.
509509

510510
// of the issuers configured, hopefully one of them is the ACME CA we got the cert from
511511
for _, iss := range cfg.Issuers {
512-
if acmeIss, ok := iss.(*ACMEIssuer); ok {
513-
newARI, err = acmeIss.getRenewalInfo(ctx, cert) // be sure to use existing newARI variable so we can compare against old value in the defer
512+
if ariGetter, ok := iss.(RenewalInfoGetter); ok {
513+
newARI, err = ariGetter.GetRenewalInfo(ctx, cert) // be sure to use existing newARI variable so we can compare against old value in the defer
514514
if err != nil {
515515
// could be anything, but a common error might simply be the "wrong" ACME CA
516516
// (meaning, different from the one that issued the cert, thus the only one
@@ -576,7 +576,7 @@ func (cfg *Config) updateARI(ctx context.Context, cert Certificate, logger *zap.
576576
}
577577
}
578578

579-
err = fmt.Errorf("could not fully update ACME renewal info: either no ACME issuer configured for certificate, or all failed (make sure the ACME CA that issued the certificate is configured)")
579+
err = fmt.Errorf("could not fully update ACME renewal info: either no issuer supporting ARI is configured for certificate, or all such failed (make sure the ACME CA that issued the certificate is configured)")
580580
return
581581
}
582582

0 commit comments

Comments
 (0)