Skip to content

Commit

Permalink
fix(client) fix parsing challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Dec 11, 2019
1 parent b513009 commit a4a37b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/resty/acme/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ function _M:order_certificate(domain_key, ...)
end

local challenges = json.decode(resp.body)
if not challenges.challenges then
goto nextchallenge
end
for _, challenge in ipairs(challenges.challenges) do
local typ = challenge.type
if self.challenge_handlers[typ] then
Expand All @@ -352,17 +355,17 @@ function _M:order_certificate(domain_key, ...)
log(ngx_DEBUG, "register challenge ", typ, ": ", challenge.token)
-- signal server to start challenge check
local resp, _, err = self:post(challenge.url, challenge)
break
end
end
::nextchallenge::
end

if registered_challenge_count == 0 then
return nil, "no challenge is registered"
end
-- Wait until the order is ready
local order_status
for _, t in pairs({1, 1, 2, 3, 5, 8, 13}) do
for _, t in pairs({1, 1, 2, 3, 5, 8, 13, 21}) do
ngx.sleep(t)
local resp, err = httpc:request_uri(order_headers["location"])
log(ngx_DEBUG, "check challenge: ", resp.body)
Expand Down

0 comments on commit a4a37b5

Please sign in to comment.