diff --git a/acme/internal/acme/acme.go b/acme/internal/acme/acme.go index b6d7efb..effc0ec 100644 --- a/acme/internal/acme/acme.go +++ b/acme/internal/acme/acme.go @@ -229,14 +229,24 @@ func (c *Client) Register(a *Account, prompt func(tos string) bool) (*Account, e // GetReg retrieves an existing registration. // The url argument is an Account URI. func (c *Client) GetReg(url string) (*Account, error) { - a := &Account{URI: url} - return c.doReg(url, "reg", a) + a, err := c.doReg(url, "reg", nil) + if err != nil { + return nil, err + } + a.URI = url + return a, nil } // UpdateReg updates an existing registration. // It returns an updated account copy. The provided account is not modified. func (c *Client) UpdateReg(a *Account) (*Account, error) { - return c.doReg(a.URI, "reg", a) + uri := a.URI + a, err := c.doReg(uri, "reg", a) + if err != nil { + return nil, err + } + a.URI = uri + return a, nil } // Authorize performs the initial step in an authorization flow. diff --git a/acme/internal/acme/acme_test.go b/acme/internal/acme/acme_test.go index f8c1d53..3237b09 100644 --- a/acme/internal/acme/acme_test.go +++ b/acme/internal/acme/acme_test.go @@ -205,6 +205,9 @@ func TestUpdateReg(t *testing.T) { if a.CurrentTerms != terms { t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, terms) } + if a.URI != ts.URL { + t.Errorf("a.URI = %q; want %q", a.URI, ts.URL) + } } func TestGetReg(t *testing.T) { @@ -266,6 +269,9 @@ func TestGetReg(t *testing.T) { if a.CurrentTerms != newTerms { t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, newTerms) } + if a.URI != ts.URL { + t.Errorf("a.URI = %q; want %q", a.URI, ts.URL) + } } func TestAuthorize(t *testing.T) {