Skip to content

Commit 109c31e

Browse files
committed
Merge branch 'delete-dehydrated-cert-files-failures' of https://github.com/Cargo/lua-resty-auto-ssl into Cargo-delete-dehydrated-cert-files-failures
2 parents f66bb61 + 05bfd53 commit 109c31e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/resty/auto-ssl/ssl_providers/lets_encrypt.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local _M = {}
22

3+
local shell_blocking = require "shell-games"
34
local shell_execute = require "resty.auto-ssl.utils.shell_execute"
45

56
function _M.issue_cert(auto_ssl_instance, domain)
@@ -36,8 +37,17 @@ function _M.issue_cert(auto_ssl_instance, domain)
3637
"--config", base_dir .. "/letsencrypt/config",
3738
"--hook", lua_root .. "/bin/resty-auto-ssl/letsencrypt_hooks",
3839
})
40+
3941
if result["status"] ~= 0 then
4042
ngx.log(ngx.ERR, "auto-ssl: dehydrated failed: ", result["command"], " status: ", result["status"], " out: ", result["output"], " err: ", err)
43+
-- remove the created files from dehydrated's cert directory
44+
assert(string.find(domain, "/") == nil)
45+
assert(string.find(domain, "%.%.") == nil)
46+
local dir = auto_ssl_instance:get("dir") .. "/letsencrypt/certs/" .. domain
47+
local _, rm_err = shell_blocking.capture_combined({ "rm", "-rf", dir })
48+
if rm_err then
49+
ngx.log(ngx.ERR, "auto-ssl: failed to cleanup certs: ", rm_err)
50+
end
4151
return nil, "dehydrated failure"
4252
end
4353

0 commit comments

Comments
 (0)