-
Notifications
You must be signed in to change notification settings - Fork 182
Delete certificates that can't be renewed #128
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,10 @@ function _M.set_cert(self, domain, fullchain_pem, privkey_pem, cert_pem, expiry) | |
return self.adapter:set(domain .. ":latest", string) | ||
end | ||
|
||
function _M.delete_cert(self, domain) | ||
return self.adapter:delete(domain .. ":latest") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming we keep the ability to retain some old certificates (as discussed in #124), should this While deleting all the versions might somewhat defeat the purpose of retaining those backups, I'm not sure we'd have a very clean way to remove the old timestamped versions once the |
||
end | ||
|
||
function _M.all_cert_domains(self) | ||
local keys, err = self.adapter:keys_with_suffix(":latest") | ||
if err then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,30 @@ function _M.delete(self, key) | |
return connection:del(prefixed_key(self, key)) | ||
end | ||
|
||
function _M.keys_with_prefix(self, prefix) | ||
local connection, connection_err = self:get_connection() | ||
if connection_err then | ||
return false, connection_err | ||
end | ||
|
||
local keys, err = connection:keys(prefixed_key(self, prefix .. "*")) | ||
|
||
if keys and self.options["prefix"] then | ||
local unprefixed_keys = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we change the |
||
-- First character past the prefix and a colon | ||
local offset = string.len(self.options["prefix"]) + 2 | ||
|
||
for _, key in ipairs(keys) do | ||
local unprefixed = string.sub(key, offset) | ||
table.insert(unprefixed_keys, unprefixed) | ||
end | ||
|
||
keys = unprefixed_keys | ||
end | ||
|
||
return keys, err | ||
end | ||
|
||
function _M.keys_with_suffix(self, suffix) | ||
local connection, connection_err = self:get_connection() | ||
if connection_err then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather basing the missing
expiry
times on the storage key's timestamps, what about instead usingrun_command
to run the same shell commands we use to fetch this directly from the certificate data usingopenssl
? https://github.com/GUI/lua-resty-auto-ssl/blob/v0.12.0/bin/letsencrypt_hooks#L37 It would require writing the cert data to a temporary file on disk, but since this should only need to happen to upgrade pre-v0.12 data once, this overhead doesn't seem like it would be a big deal.It seems like this approach would ensure better consistency, since we'd be sure we get the accurate expiration time directly out of the certificate (in case the timestamp it was stored at was different for whatever reason). It would also work, even if we made changes to potentially get rid of the old timestamped certs from storage, as discussed in #124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This idea made sense to me. I went for the timestamps, since it seemed more obtainable (I am still only dabbling in Lua).
Note that getting rid of newly-created backups down the line would not cause an issue here, as all certificates created after af15771 already have the
expiry
information set.