Skip to content

Commit

Permalink
Move ocsp_response_cache:delete after certificate_data:set
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzong committed Sep 19, 2020
1 parent ff3b431 commit 87e79da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rootfs/etc/nginx/lua/configuration.lua
Expand Up @@ -101,13 +101,19 @@ local function handle_servers()
end

for uid, cert in pairs(configuration.certificates) do
-- don't delete the cache here, certificate_data[uid] is not replaced yet.
-- there is small chance that nginx worker still get the old certificate,
-- then fetch and cache the old OCSP Response
local old_cert = certificate_data:get(uid)
if old_cert ~= nil and old_cert ~= cert then
ocsp_response_cache:delete(uid)
end
local is_renew = (old_cert ~= nil and old_cert ~= cert)

local success, set_err, forcible = certificate_data:set(uid, cert)
if not success then
if success then
-- delete ocsp cache after certificate_data:set succeed
if is_renew then
ocsp_response_cache:delete(uid)
end
else
local err_msg = string.format("error setting certificate for %s: %s\n",
uid, tostring(set_err))
table.insert(err_buf, err_msg)
Expand Down

0 comments on commit 87e79da

Please sign in to comment.