jxskiss / simplessl

On the fly SSL certificate issue and renewal inside OpenResty with Let's Encrypt
MIT License
45 stars 13 forks source link

Error in ssl-cert-server.lua:375 when SSL server returns no certificate #2

Closed rtf6x closed 3 years ago

rtf6x commented 3 years ago

There's an error when ssl server returns nil instead of certificate. Fixed it this way:

(ssl-cert-server/lib/resty/ssl-cert-server.lua:369):

if cert then
    -- Since certificate renewal happens far before expired on backend server,
    -- most probably the previous certificate is valid, we use it if it is available.
    -- This avoids further requests within next cache period triggering certificate
    -- requests to backend, which may slow down nginx and rise up pressure on busy site.
    -- Also we consider an recently-expired certificate is more friendly to our users
    -- than fallback to self-signed certificate.
    if cert.expire_at <= ngx_time() then
        is_expired = true
        ngx_log(ngx_ERR, domain, ": fallback to expired certificate")
    end
else
    is_expired = true
    ngx_log(ngx_ERR, domain, ": fallback to expired certificate (no cert)")
end