Skip to content

Commit a1e1bd6

Browse files
committed
More logging about account loading/creation
1 parent ed73243 commit a1e1bd6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

account.go

+8
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,23 @@ import (
3333
"sync"
3434

3535
"github.com/mholt/acmez/v2/acme"
36+
"go.uber.org/zap"
3637
)
3738

3839
// getAccount either loads or creates a new account, depending on if
3940
// an account can be found in storage for the given CA + email combo.
4041
func (am *ACMEIssuer) getAccount(ctx context.Context, ca, email string) (acme.Account, error) {
4142
acct, err := am.loadAccount(ctx, ca, email)
4243
if errors.Is(err, fs.ErrNotExist) {
44+
am.Logger.Info("creating new account because no account for configured email is known to us",
45+
zap.String("email", email),
46+
zap.String("ca", ca),
47+
zap.Error(err))
4348
return am.newAccount(email)
4449
}
50+
am.Logger.Debug("using existing ACME account because key found in storage associated with email",
51+
zap.String("email", email),
52+
zap.String("ca", ca))
4553
return acct, err
4654
}
4755

acmeclient.go

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (iss *ACMEIssuer) newACMEClientWithAccount(ctx context.Context, useTestCA,
5353
// look up or create the ACME account
5454
var account acme.Account
5555
if iss.AccountKeyPEM != "" {
56+
iss.Logger.Info("using configured ACME account")
5657
account, err = iss.GetAccount(ctx, []byte(iss.AccountKeyPEM))
5758
} else {
5859
account, err = iss.getAccount(ctx, client.Directory, iss.getEmail())
@@ -63,6 +64,10 @@ func (iss *ACMEIssuer) newACMEClientWithAccount(ctx context.Context, useTestCA,
6364

6465
// register account if it is new
6566
if account.Status == "" {
67+
iss.Logger.Info("ACME account has empty status; registering account with ACME server",
68+
zap.Strings("contact", account.Contact),
69+
zap.String("location", account.Location))
70+
6671
if iss.NewAccountFunc != nil {
6772
// obtain lock here, since NewAccountFunc calls happen concurrently and they typically read and change the issuer
6873
iss.mu.Lock()
@@ -116,6 +121,9 @@ func (iss *ACMEIssuer) newACMEClientWithAccount(ctx context.Context, useTestCA,
116121
if err != nil {
117122
return nil, fmt.Errorf("registering account %v with server: %w", account.Contact, err)
118123
}
124+
iss.Logger.Info("new ACME account registered",
125+
zap.Strings("contact", account.Contact),
126+
zap.String("status", account.Status))
119127

120128
// persist the account to storage
121129
err = iss.saveAccount(ctx, client.Directory, account)

0 commit comments

Comments
 (0)