loadAccount loads an account from storage, but does not create a new one.
(ctx context.Context, ca, email string)
| 73 | |
| 74 | // loadAccount loads an account from storage, but does not create a new one. |
| 75 | func (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. |
no test coverage detected