Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport -> release/3.5.x] fix(plugins/acme): fix certificate renew failure issue #12801

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/kong/fix-acme-renewal-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: "**ACME**: Fixed an issue where the certificate was not successfully renewed during ACME renewal."
type: bugfix
scope: Plugin
2 changes: 1 addition & 1 deletion kong/plugins/acme/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ return {
end,

PATCH = function()
ngx_timer_at(0, client.renew_certificate)
ngx_timer_at(0, handler.renew)
return kong.response.exit(202, { message = "Renewal process started successfully" })
end,
},
Expand Down
3 changes: 3 additions & 0 deletions kong/plugins/acme/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ local function renew(premature)
end


ACMEHandler.renew = renew


function ACMEHandler:init_worker()
local worker_id = ngx.worker.id()
kong.log.info("acme renew timer started on worker ", worker_id)
Expand Down
12 changes: 12 additions & 0 deletions spec/03-plugins/29-acme/01-client_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,18 @@ for _, strategy in ipairs({"off"}) do
assert.is_nil(err)
assert.is_falsy(renew)
end)

it("calling handler.renew with a false argument should be successful", function()
local handler = require("kong.plugins.acme.handler")
handler:configure({{domains = {"example.com"}}})

local original = client.renew_certificate
client.renew_certificate = function (config)
print("mock renew_certificate")
end
handler.renew(false)
client.renew_certificate = original
end)
end)

end)
Expand Down
Loading