OpenResty lua-resty-http unable to get local issuer certificate

OpenResty HTTPS About 451 words

错误信息

在请求https接口时,抛出了如下异常信息:

lua ssl certificate verify error: (20: unable to get local issuer certificate)

错误原因

lua-resty-http默认是开启了证书校验,而Nginx本地的证书与请求地址的证书不一致导致。

解决方法

lua-resty-http中发起请求时添加ssl_verify = false选项。

local http = require "resty.http"

local httpc = http.new()
local res, err = httpc:request_uri('https://www.test.com', {
    ssl_verify = false, -- 不校验证书
    keepalive_timeout = 2000 -- 毫秒
})

参考

https://github.com/ledgetech/lua-resty-http

Views: 4,890 · Posted: 2021-05-09

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh