auto-ssl / lua-resty-auto-ssl

On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.
MIT License
1.94k stars 181 forks source link

Failing to use the 'has_certificate' method #283

Open petitiaux opened 2 years ago

petitiaux commented 2 years ago

I'm looking to forward http traffic to https, if there is a certificate found. We're using the has_certificate method for this. We've implemented the example code but nginx fails with the following log line:

lua entry thread aborted: runtime error: rewrite_by_lua(default.conf:34):2: attempt to call method 'has_certificate' (a nil value)

I've placed the code inside the server block listening on port 80.

Any help is greatly appreciated!

acatalina commented 2 years ago

I had the same issue. Not much inside that function:

 local storage = auto_ssl.storage
 local cert = storage:get_cert(domain)

-- check if cert exists then do...

for reference https://github.com/auto-ssl/lua-resty-auto-ssl/blob/71259605a3868b287ac0501d5850594b3f1b9cbb/lib/resty/auto-ssl/utils/has_certificate.lua

devopswimg commented 1 month ago

@petitiaux @acatalina were you able to solve it ? Happening the same thing on my case

acatalina commented 1 month ago

hey @devopswimg, I had to look at the code to remember what I did hehe it looks like rather than calling has_certificate, I did what that function does directly.

 local storage = auto_ssl.storage
 local cert = storage:get_cert(domain)
devopswimg commented 3 weeks ago

Awesome Thanks @acatalina !!