Skip to content

Commit 19bbefb

Browse files
authored
fix: don't generate ARI cert ID if ARI is not enable (go-acme#2138)
1 parent 719d26c commit 19bbefb

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

cmd/cmd_renew.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ func renewForDomains(ctx *cli.Context, client *lego.Client, certsStorage *Certif
187187
time.Sleep(sleepTime)
188188
}
189189

190-
replacesCertID, err := certificate.MakeARICertID(cert)
191-
if err != nil {
192-
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
193-
}
194-
195190
request := certificate.ObtainRequest{
196191
Domains: merge(certDomains, domains),
197192
PrivateKey: privateKey,
@@ -201,7 +196,13 @@ func renewForDomains(ctx *cli.Context, client *lego.Client, certsStorage *Certif
201196
Bundle: bundle,
202197
PreferredChain: ctx.String("preferred-chain"),
203198
AlwaysDeactivateAuthorizations: ctx.Bool("always-deactivate-authorizations"),
204-
ReplacesCertID: replacesCertID,
199+
}
200+
201+
if ctx.Bool("ari-enable") {
202+
request.ReplacesCertID, err = certificate.MakeARICertID(cert)
203+
if err != nil {
204+
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
205+
}
205206
}
206207

207208
certRes, err := client.Certificate.Obtain(request)
@@ -262,19 +263,20 @@ func renewForCSR(ctx *cli.Context, client *lego.Client, certsStorage *Certificat
262263
timeLeft := cert.NotAfter.Sub(time.Now().UTC())
263264
log.Infof("[%s] acme: Trying renewal with %d hours remaining", domain, int(timeLeft.Hours()))
264265

265-
replacesCertID, err := certificate.MakeARICertID(cert)
266-
if err != nil {
267-
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
268-
}
269-
270266
request := certificate.ObtainForCSRRequest{
271267
CSR: csr,
272268
NotBefore: getTime(ctx, "not-before"),
273269
NotAfter: getTime(ctx, "not-after"),
274270
Bundle: bundle,
275271
PreferredChain: ctx.String("preferred-chain"),
276272
AlwaysDeactivateAuthorizations: ctx.Bool("always-deactivate-authorizations"),
277-
ReplacesCertID: replacesCertID,
273+
}
274+
275+
if ctx.Bool("ari-enable") {
276+
request.ReplacesCertID, err = certificate.MakeARICertID(cert)
277+
if err != nil {
278+
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
279+
}
278280
}
279281

280282
certRes, err := client.Certificate.ObtainForCSR(request)

0 commit comments

Comments
 (0)