Skip to content

Commit

Permalink
Add PollInterval to ZeroSSLIssuer (caddyserver#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
aplr authored Oct 24, 2024
1 parent 65cf36c commit 7afeaee
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions zerosslissuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type ZeroSSLIssuer struct {
// validation, set this field.
CNAMEValidation *DNSManager

// Delay between poll attempts.
PollInterval time.Duration

// An optional (but highly recommended) logger.
Logger *zap.Logger
}
Expand Down Expand Up @@ -203,8 +206,8 @@ func (iss *ZeroSSLIssuer) Issue(ctx context.Context, csr *x509.CertificateReques
}, nil
}

func (*ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.Client, cert zerossl.CertificateObject) (zerossl.CertificateObject, error) {
ticker := time.NewTicker(5 * time.Second)
func (iss *ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.Client, cert zerossl.CertificateObject) (zerossl.CertificateObject, error) {
ticker := time.NewTicker(iss.pollInterval())
defer ticker.Stop()

for {
Expand All @@ -227,6 +230,13 @@ func (*ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.
}
}

func (iss *ZeroSSLIssuer) pollInterval() time.Duration {
if iss.PollInterval == 0 {
return defaultPollInterval
}
return iss.PollInterval
}

func (iss *ZeroSSLIssuer) getClient() zerossl.Client {
return zerossl.Client{AccessKey: iss.APIKey}
}
Expand Down Expand Up @@ -302,6 +312,7 @@ const (
zerosslAPIBase = "https://" + zerossl.BaseURL + "/acme"
zerosslValidationPathPrefix = "/.well-known/pki-validation/"
zerosslIssuerKey = "zerossl"
defaultPollInterval = 5 * time.Second
)

// Interface guards
Expand Down

0 comments on commit 7afeaee

Please sign in to comment.