@@ -311,35 +311,34 @@ local function new_order(applet)
311
311
end
312
312
313
313
-- Place new order
314
- resp , err = acme :post {url = acme .resources [" newOrder" ], data = order_payload ,
314
+ local order , err = acme :post {url = acme .resources [" newOrder" ], data = order_payload ,
315
315
resource = " newOrder" }
316
- if not resp then
316
+ if not order then
317
317
return http .response .create {status_code = 500 , data = err }:send (applet )
318
- else if resp .status_code ~= 201 then
319
- return resp :send (applet )
318
+ elseif order .status_code ~= 201 then
319
+ return order :send (applet )
320
320
end
321
321
322
- local resp_json = resp :json ()
323
- local finalize = resp_json .finalize
324
- local authorizations = resp_json .authorizations
322
+ local order_json = order :json ()
325
323
326
- for _ , auth in ipairs (authorizations ) do
324
+ for _ , auth in ipairs (order_json . authorizations ) do
327
325
--
328
326
local auth_payload = {
329
327
keyAuthorization = nil
330
328
}
331
329
332
330
-- Get auth token
333
- local resp , err = http .get {url = acme :proxy_url (auth )}
331
+ local auth , err = http .get {url = acme :proxy_url (auth )}
334
332
335
- if resp then
336
- local auth_resp = resp :json ()
333
+ if auth then
334
+ local auth_json = auth :json ()
337
335
338
- for _ , ch in ipairs (auth_resp .challenges ) do
336
+ for _ , ch in ipairs (auth_json .challenges ) do
339
337
if ch .type == " http-01" then
340
338
http_challenges [ch .token ] = string.format (" %s.%s" ,
341
339
ch .token , acme .account .thumbprint )
342
- resp , err = acme :post {url = ch .url , data = ch , resource = " challengeDone" , timeout = 1 }
340
+ resp , err = acme :post {url = ch .url , data = ch ,
341
+ resource = " challengeDone" , timeout = 1 }
343
342
end
344
343
end
345
344
end
@@ -370,7 +369,8 @@ local function new_order(applet)
370
369
csr = http .base64 .encode (csr :tostring (" DER" ), base64enc )
371
370
}
372
371
373
- resp , err = acme :post {url = finalize , data = payload , resource = " finalizeOrder" }
372
+ resp , err = acme :post {url = order_json .finalize , data = payload ,
373
+ resource = " finalizeOrder" }
374
374
375
375
if resp and resp .status_code == 200 then
376
376
local resp_json = resp :json ()
0 commit comments