MCPcopy
hub / github.com/caddyserver/certmagic / loadAccount

Method loadAccount

account.go:75–96  ·  view source on GitHub ↗

loadAccount loads an account from storage, but does not create a new one.

(ctx context.Context, ca, email string)

Source from the content-addressed store, hash-verified

73
74// loadAccount loads an account from storage, but does not create a new one.
75func (am *ACMEIssuer) loadAccount(ctx context.Context, ca, email string) (acme.Account, error) {
76 regBytes, err := am.config.Storage.Load(ctx, am.storageKeyUserReg(ca, email))
77 if err != nil {
78 return acme.Account{}, err
79 }
80 keyBytes, err := am.config.Storage.Load(ctx, am.storageKeyUserPrivateKey(ca, email))
81 if err != nil {
82 return acme.Account{}, err
83 }
84
85 var acct acme.Account
86 err = json.Unmarshal(regBytes, &acct)
87 if err != nil {
88 return acct, err
89 }
90 acct.PrivateKey, err = PEMDecodePrivateKey(keyBytes)
91 if err != nil {
92 return acct, fmt.Errorf("could not decode account's private key: %v", err)
93 }
94
95 return acct, nil
96}
97
98// newAccount generates a new private key for a new ACME account, but
99// it does not register or save the account.

Callers 3

loadOrCreateAccountMethod · 0.95
GetAccountMethod · 0.95
loadAccountByKeyMethod · 0.95

Calls 4

storageKeyUserRegMethod · 0.95
PEMDecodePrivateKeyFunction · 0.85
LoadMethod · 0.65

Tested by

no test coverage detected