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

Commit 45a50e4

Browse files
author
Adis Nezirovic
committed
BUG/MEDIUM: Delete the challenge token only after auth is finished.
1 parent 62d3b06 commit 45a50e4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

acme.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ local function new_order(applet)
320320
end
321321

322322
local order_json = order:json()
323+
local challenge_token
323324

324325
for _, auth in ipairs(order_json.authorizations) do
325326
--
@@ -339,13 +340,18 @@ local function new_order(applet)
339340
ch.token, acme.account.thumbprint)
340341
resp, err = acme:post{url=ch.url, data=ch,
341342
resource="challengeDone", timeout=1}
343+
challenge_token = ch.token
344+
break
342345
end
343346
end
344347
end
345348
end
346349

347350
-- TODO: Check pending status in a loop
348351
core.sleep(5)
352+
if challenge_token and http_challenges[challenge_token] then
353+
http_challenges[challenge_token] = nil
354+
end
349355

350356
-- CSR creation
351357
local dn = openssl.name.new()
@@ -390,10 +396,9 @@ end
390396
local function acme_challenge(applet)
391397
local p = core.tokenize(applet.path, "/", true)
392398
if not p[3] or not http_challenges[p[3]] then
393-
http.response.create{status_code=404}:send(applet)
399+
return http.response.create{status_code=404}:send(applet)
394400
end
395401
http.response.create{status_code=200, content=http_challenges[p[3]]}:send(applet)
396-
http_challenges[p[3]] = nil
397402
end
398403

399404
--- Request handler/router

0 commit comments

Comments
 (0)