Skip to content

Commit 49256f8

Browse files
committed
Delete extra cert files after adding the cert to storage
dehydrated creates 5 files per domain, per renewal. While they are not big in size, a seizable number of (sub-) domains can this silently exhaust the number of available inodes.
1 parent 26ac1d9 commit 49256f8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/resty/auto-ssl/servers/hook.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local run_command = require "resty.auto-ssl.utils.run_command"
2+
13
-- This server provides an internal-only API for the dehydrated bash hook
24
-- script to call. This allows for storing the tokens or certificates in the
35
-- configured storage adapter (which allows for non-local storage mechanisms
@@ -45,6 +47,11 @@ return function(auto_ssl_instance)
4547
ngx.log(ngx.ERR, "auto-ssl: failed to set cert: ", err)
4648
return ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
4749
end
50+
-- remove the extra copy of the certificate files in dehydrated's cert directory
51+
assert(string.find(params["domain"], "/") == nil)
52+
assert(string.find(params["domain"], "%.%.") == nil)
53+
local dir = auto_ssl_instance:get("dir") .. "/letsencrypt/certs/" .. params["domain"]
54+
run_command("rm -rf " .. dir)
4855
else
4956
ngx.log(ngx.ERR, "auto-ssl: unknown request to hook server: ", path)
5057
return ngx.exit(ngx.HTTP_NOT_FOUND)

0 commit comments

Comments
 (0)