Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 3c5dff3

Browse files
author
Adis Nezirovic
committed
MEDIUM: Check for order status before downloading cert.
1 parent 45a50e4 commit 3c5dff3

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

acme.lua

+24-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,30 @@ local function new_order(applet)
347347
end
348348
end
349349

350-
-- TODO: Check pending status in a loop
351-
core.sleep(5)
350+
-- Wait until the order is ready
351+
local order_status
352+
for _, t in pairs({1, 1, 2, 3, 5, 8, 13}) do
353+
core.sleep(t)
354+
local resp, err = http.get{url=acme:proxy_url(order.headers["location"])}
355+
if resp then
356+
order_status = resp:json()
357+
if order_status.status == "ready" then
358+
break
359+
elseif order_status.status == "invalid" then
360+
return resp:send(applet)
361+
end
362+
end
363+
end
364+
365+
if not order_status then
366+
return http.response.create{status_code=500,
367+
content="Could not get order status"}:send(applet)
368+
end
369+
370+
if order_status.status ~= "ready" then
371+
return http.response.create{status_code=500, content=order_status}:send(applet)
372+
end
373+
352374
if challenge_token and http_challenges[challenge_token] then
353375
http_challenges[challenge_token] = nil
354376
end

0 commit comments

Comments
 (0)