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

Commit 72d0395

Browse files
author
Adis Nezirovic
committed
MINOR: Indentation
1 parent 63bde58 commit 72d0395

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

acme.lua

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -317,73 +317,73 @@ local function new_order(applet)
317317
return http.response.create{status_code=500, data=err}:send(applet)
318318
end
319319

320-
-- if resp.code == 201
321-
local resp_json = resp:json()
322-
local finalize = resp_json.finalize
323-
local authorizations = resp_json.authorizations
324-
325-
for _, auth in ipairs(authorizations) do
326-
--
327-
local auth_payload = {
328-
keyAuthorization = nil
329-
}
320+
-- if resp.code == 201
321+
local resp_json = resp:json()
322+
local finalize = resp_json.finalize
323+
local authorizations = resp_json.authorizations
324+
325+
for _, auth in ipairs(authorizations) do
326+
--
327+
local auth_payload = {
328+
keyAuthorization = nil
329+
}
330330

331-
-- Get auth token
332-
local resp, err = http.get{url=acme:proxy_url(auth)}
331+
-- Get auth token
332+
local resp, err = http.get{url=acme:proxy_url(auth)}
333333

334-
if resp then
335-
local auth_resp = resp:json()
334+
if resp then
335+
local auth_resp = resp:json()
336336

337-
for _, ch in ipairs(auth_resp.challenges) do
338-
if ch.type == "http-01" then
339-
http_challenges[ch.token] = string.format("%s.%s",
340-
ch.token, acme.account.thumbprint)
341-
resp, err = acme:post{url=ch.url, data=ch, resource="challengeDone", timeout=1}
342-
end
337+
for _, ch in ipairs(auth_resp.challenges) do
338+
if ch.type == "http-01" then
339+
http_challenges[ch.token] = string.format("%s.%s",
340+
ch.token, acme.account.thumbprint)
341+
resp, err = acme:post{url=ch.url, data=ch, resource="challengeDone", timeout=1}
343342
end
344343
end
345344
end
345+
end
346346

347-
-- TODO: Check pending status in a loop
348-
core.sleep(5)
347+
-- TODO: Check pending status in a loop
348+
core.sleep(5)
349349

350-
-- CSR creation
351-
local dn = openssl.name.new()
352-
dn:add("CN", form.domain)
350+
-- CSR creation
351+
local dn = openssl.name.new()
352+
dn:add("CN", form.domain)
353353

354-
local alt = openssl.altname.new()
355-
alt:add("DNS", form.domain)
354+
local alt = openssl.altname.new()
355+
alt:add("DNS", form.domain)
356356

357-
for _, alias in pairs(aliases) do
358-
alt:add("DNS", alias)
359-
end
357+
for _, alias in pairs(aliases) do
358+
alt:add("DNS", alias)
359+
end
360360

361-
local csr = openssl.csr.new()
362-
csr:setSubject(dn)
363-
csr:setSubjectAlt(alt)
361+
local csr = openssl.csr.new()
362+
csr:setSubject(dn)
363+
csr:setSubjectAlt(alt)
364364

365-
local key = openssl.pkey.new(form.domain_key.data or form.domain_key)
366-
csr:setPublicKey(key)
367-
csr:sign(key)
368-
local payload = {
369-
csr = http.base64.encode(csr:tostring("DER"), base64enc)
370-
}
371-
372-
resp, err = acme:post{url=finalize, data=payload, resource="finalizeOrder"}
365+
local key = openssl.pkey.new(form.domain_key.data or form.domain_key)
366+
csr:setPublicKey(key)
367+
csr:sign(key)
368+
local payload = {
369+
csr = http.base64.encode(csr:tostring("DER"), base64enc)
370+
}
373371

374-
if resp and resp.status_code == 200 then
375-
local resp_json = resp:json()
372+
resp, err = acme:post{url=finalize, data=payload, resource="finalizeOrder"}
376373

377-
if not resp_json.certificate then
378-
return http.response.create{status_code=500, content="No cert"}:send(applet)
379-
end
374+
if resp and resp.status_code == 200 then
375+
local resp_json = resp:json()
380376

381-
local resp, err = http.get{url=acme:proxy_url(resp_json.certificate)}
382-
local bundle = string.format("%s%s", resp.content, key:toPEM("private"))
383-
return http.response.create{status_code=200, content=bundle}:send(applet)
384-
else
385-
return resp:send(applet)
377+
if not resp_json.certificate then
378+
return http.response.create{status_code=500, content="No cert"}:send(applet)
386379
end
380+
381+
local resp, err = http.get{url=acme:proxy_url(resp_json.certificate)}
382+
local bundle = string.format("%s%s", resp.content, key:toPEM("private"))
383+
return http.response.create{status_code=200, content=bundle}:send(applet)
384+
else
385+
return resp:send(applet)
386+
end
387387
end
388388

389389
local function acme_challenge(applet)

0 commit comments

Comments
 (0)