Skip to content

Commit 4e5209d

Browse files
committed
Fail silently if there is no OCSP server
1 parent 7125960 commit 4e5209d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/resty/auto-ssl/ssl_certificate.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ end
159159
local function get_ocsp_response(fullchain_der, auto_ssl_instance)
160160
-- Pull the OCSP URL to hit out of the certificate chain.
161161
local ocsp_url, ocsp_responder_err = ocsp.get_ocsp_responder_from_der_chain(fullchain_der)
162-
if not ocsp_url then
162+
if not ocsp_url and not ocsp_responder_err then
163+
-- There is no OCSP responder, stop silently
164+
return "", nil
165+
elseif not ocsp_url then
163166
return nil, "failed to get OCSP responder: " .. (ocsp_responder_err or "")
164167
end
165168

@@ -211,7 +214,7 @@ local function set_ocsp_stapling(domain, cert_der, auto_ssl_instance)
211214
-- Fetch the OCSP stapling response from the cache, or make the request to
212215
-- fetch it.
213216
local ocsp_resp = ngx.shared.auto_ssl:get("domain:ocsp:" .. domain)
214-
if not ocsp_resp then
217+
if ocsp_resp then
215218
-- If the certificate was just issued on the current request, wait 1 second
216219
-- before making the initial OCSP request. Otherwise Let's Encrypt seems to
217220
-- return an Unauthorized response.
@@ -236,9 +239,11 @@ local function set_ocsp_stapling(domain, cert_der, auto_ssl_instance)
236239
end
237240

238241
-- Set the OCSP stapling response.
239-
local ok, ocsp_status_err = ocsp.set_ocsp_status_resp(ocsp_resp)
240-
if not ok then
241-
return false, "failed to set ocsp status resp: " .. (ocsp_status_err or "")
242+
if ocsp_resp ~= "" then
243+
local ok, ocsp_status_err = ocsp.set_ocsp_status_resp(ocsp_resp)
244+
if not ok then
245+
return false, "failed to set ocsp status resp: " .. (ocsp_status_err or "")
246+
end
242247
end
243248

244249
return true

0 commit comments

Comments
 (0)