From 599eb9a739ee91e8a4df2fca5b56c490ab965d2a Mon Sep 17 00:00:00 2001 From: Till Klocke Date: Mon, 6 Jun 2016 14:13:45 +0200 Subject: [PATCH 1/2] In case of conflict during registration, the old registration is now recovered --- acme/client.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/acme/client.go b/acme/client.go index 5bda6bc2..a2d9c0ed 100644 --- a/acme/client.go +++ b/acme/client.go @@ -167,15 +167,29 @@ func (c *Client) Register() (*RegistrationResource, error) { } var serverReg Registration + var regURI string hdr, err := postJSON(c.jws, c.directory.NewRegURL, regMsg, &serverReg) if err != nil { - return nil, err + remoteErr, ok := err.(RemoteError) + if ok && remoteErr.StatusCode == 409 { + regURI = hdr.Get("Location") + regMsg.Resource = "reg" + if hdr, err = postJSON(c.jws, regURI, regMsg, &serverReg); err != nil { + return nil, err + } + } else { + return nil, err + } } reg := &RegistrationResource{Body: serverReg} links := parseLinks(hdr["Link"]) - reg.URI = hdr.Get("Location") + + if regURI == "" { + regURI = hdr.Get("Location") + } + reg.URI = regURI if links["terms-of-service"] != "" { reg.TosURL = links["terms-of-service"] } From 402756c1c5c4a76011ba9effc5df33bdcb7eb29e Mon Sep 17 00:00:00 2001 From: Till Klocke Date: Tue, 14 Jun 2016 09:50:12 +0200 Subject: [PATCH 2/2] registration message in case of conflict 409 should not contain contact details --- acme/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/acme/client.go b/acme/client.go index a2d9c0ed..fe012222 100644 --- a/acme/client.go +++ b/acme/client.go @@ -173,7 +173,9 @@ func (c *Client) Register() (*RegistrationResource, error) { remoteErr, ok := err.(RemoteError) if ok && remoteErr.StatusCode == 409 { regURI = hdr.Get("Location") - regMsg.Resource = "reg" + regMsg = registrationMessage{ + Resource: "reg", + } if hdr, err = postJSON(c.jws, regURI, regMsg, &serverReg); err != nil { return nil, err }