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 3 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
16 changes: 15 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,23 @@ function AUTOSSL.check_renew(premature)
goto continue
end

local domain = deserialized.domain
if not AUTOSSL.is_domain_whitelisted(domain, true) then
log(ngx_INFO, "domain ", domain, " not in whitelist, skipping")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log(ngx_INFO, "domain ", domain, " not in whitelist, skipping")
log(ngx_INFO, "domain ", domain, " not in whitelist but exists in storage, skipping renewal")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you will actually delete the not whitelisted domain afterwards, it's not always "skipping". so this log line will need to move to after Line 345 and don't show if AUTOSSL.config.enabled_delete_not_whitelisted_domain is true.

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
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