Skip to content

Commit

Permalink
fix: don't generate ARI cert ID if ARI is not enable (#2138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Mar 10, 2024
1 parent 719d26c commit 19bbefb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions cmd/cmd_renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ func renewForDomains(ctx *cli.Context, client *lego.Client, certsStorage *Certif
time.Sleep(sleepTime)
}

replacesCertID, err := certificate.MakeARICertID(cert)
if err != nil {
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
}

request := certificate.ObtainRequest{
Domains: merge(certDomains, domains),
PrivateKey: privateKey,
Expand All @@ -201,7 +196,13 @@ func renewForDomains(ctx *cli.Context, client *lego.Client, certsStorage *Certif
Bundle: bundle,
PreferredChain: ctx.String("preferred-chain"),
AlwaysDeactivateAuthorizations: ctx.Bool("always-deactivate-authorizations"),
ReplacesCertID: replacesCertID,
}

if ctx.Bool("ari-enable") {
request.ReplacesCertID, err = certificate.MakeARICertID(cert)
if err != nil {
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
}
}

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

replacesCertID, err := certificate.MakeARICertID(cert)
if err != nil {
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
}

request := certificate.ObtainForCSRRequest{
CSR: csr,
NotBefore: getTime(ctx, "not-before"),
NotAfter: getTime(ctx, "not-after"),
Bundle: bundle,
PreferredChain: ctx.String("preferred-chain"),
AlwaysDeactivateAuthorizations: ctx.Bool("always-deactivate-authorizations"),
ReplacesCertID: replacesCertID,
}

if ctx.Bool("ari-enable") {
request.ReplacesCertID, err = certificate.MakeARICertID(cert)
if err != nil {
log.Fatalf("Error while construction the ARI CertID for domain %s\n\t%v", domain, err)
}
}

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

0 comments on commit 19bbefb

Please sign in to comment.