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

Option to delete none whitelisted domains in certificate update #112

Merged
merged 4 commits into from
Mar 27, 2024
Merged
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
17 changes: 16 additions & 1 deletion lib/resty/acme/autossl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ local default_config = {
challenge_start_delay = 0,
-- if true, the request to nginx waits until the cert has been generated and it is used right away
blocking = false,
enabled_delete_not_whitelisted_domain = false,
}

local domain_pkeys = {}
Expand Down Expand Up @@ -332,10 +333,24 @@ function AUTOSSL.check_renew(premature)
goto continue
end

local domain = deserialized.domain
if not AUTOSSL.is_domain_whitelisted(domain, true) then
if AUTOSSL.config.enabled_delete_not_whitelisted_domain then
local err = AUTOSSL.storage:delete(key)
if err then
log(ngx_ERR, "failed to delete certificate for ", domain, " error: ", err)
else
log(ngx_INFO, "successfully delete certificate for domain ", domain)
end
else
log(ngx_INFO, "domain ", domain, " not in whitelist but exists in storage, skipping renewal")
end
goto continue
end

local cert = openssl.x509.new(deserialized.cert)
local _, not_after = cert:get_lifetime()
if not_after - now < AUTOSSL.config.renew_threshold then
local domain = deserialized.domain
local err = AUTOSSL.update_cert({
domain = domain,
renew = true,
Expand Down
Loading