aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/client.go b/client.go
index 38d9811..7246663 100644
--- a/client.go
+++ b/client.go
@@ -214,6 +214,7 @@ func (c *Client) Authorize(a *Account, domain []string) error {
if err != nil {
return err
}
+ ns := parseHeader(resp)
switch resp.StatusCode {
case http.StatusCreated:
for _, ch := range r.Challenges {
@@ -231,10 +232,30 @@ func (c *Client) Authorize(a *Account, domain []string) error {
}
}
}
+ for {
+ az, err := c.Status(ns.Location.String())
+ if err != nil {
+ return err
+ }
+ log.Println(az)
+ log.Println(ns.RetryAfter)
+ time.Sleep(ns.RetryAfter)
+ }
}
return err
}
+func (c *Client) Status(url string) (*Authorization, error) {
+ r := &Authorization{}
+ resp, err := http.Get(url)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+ defer c.replyNonce(resp)
+ return r, json.NewDecoder(resp.Body).Decode(r)
+}
+
////////////////////////////////////////////////////////////////////////
// Register