From 698d6ae5decfd68d42fb4ed3dbcea9b75adc8d38 Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Fri, 6 Mar 2020 19:18:39 +0000 Subject: [PATCH] Don't call GetReg before Register in registerAccount Signed-off-by: James Munnelly --- pkg/issuer/acme/setup.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/issuer/acme/setup.go b/pkg/issuer/acme/setup.go index d6656408a..c099e75ef 100644 --- a/pkg/issuer/acme/setup.go +++ b/pkg/issuer/acme/setup.go @@ -301,26 +301,21 @@ func ensureEmailUpToDate(ctx context.Context, cl client.Interface, acc *acmeapi. // up and verify the corresponding account, and will return that. If this fails // due to a not found error it will register a new account with the given key. func (a *Acme) registerAccount(ctx context.Context, cl client.Interface, eabAccount *acmeapi.ExternalAccountBinding) (*acmeapi.Account, error) { - // check if the account already exists - acc, err := cl.GetReg(ctx, "") - if err == nil { - return acc, nil - } - if err != acmeapi.ErrNoAccount { - return nil, err - } - emailurl := []string(nil) if a.issuer.GetSpec().ACME.Email != "" { emailurl = []string{fmt.Sprintf("mailto:%s", strings.ToLower(a.issuer.GetSpec().ACME.Email))} } - acc = &acmeapi.Account{ + acc := &acmeapi.Account{ Contact: emailurl, ExternalAccountBinding: eabAccount, } - acc, err = cl.Register(ctx, acc, acmeapi.AcceptTOS) + acc, err := cl.Register(ctx, acc, acmeapi.AcceptTOS) + // If the account already exists, fetch the Account object and return. + if err == acmeapi.ErrAccountAlreadyExists { + return cl.GetReg(ctx, "") + } if err != nil { return nil, err }