lua-resty-letsencrypt icon indicating copy to clipboard operation
lua-resty-letsencrypt copied to clipboard

new-authz request incorrect.

Open ashb opened this issue 8 years ago • 5 comments

As discovered in #2 we are incorrectly handling the new-authz request - we get an HTTP 405 response back right now - but possibly only in some circumstances - https://github.com/torhve/lua-resty-letsencrypt/blob/29a0a8511e50397b0c4df33e0302ca4ec154bee9/letsencrypt.lua#L670 this code path in particular.

ashb avatar Apr 04 '16 21:04 ashb

So I'm not sure what state it seemed to end up in but this diff "fixed" it but I'm far from certain it's right or really all that happy with the change:

     if authz then
         while authz.body.status == "pending" do
             if authz.need_update then
-                log("Updating authz...")
-                local updated, err = account.unsigned_request(authz.head.location or authz.url)
+                local url, updated, err
+                url = authz.head.Location or authz.url
+                if url == account.get_directory()["new-authz"] then
+                  log("Restarting as a new authz...")
+                  updated, err = account.new_dns_authz(host)
+                else
+                  log("Updating authz...")
+                  updated, err = account.unsigned_request(url)
+                end
                 if not updated then
                     log("Failed to update authz: %s", tostring(err))
                     break

Note the authz.head.location vs authz.head.Location too.

ashb avatar Apr 05 '16 12:04 ashb

I think you are onto something here. Do you want to play with it a bit more before you send a pull request?

torhve avatar Apr 05 '16 14:04 torhve

Sure. I'll see if there's a better way of telling if we need to do a get vs a new post rather than comparing URLs.

ashb avatar Apr 05 '16 15:04 ashb

@ashb ping? have you any news about your potential PR? :D

msva avatar May 17 '17 17:05 msva

Never got around to it and moved on to other things, sorry :(

ashb avatar May 17 '17 17:05 ashb