Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

如何解决openresty lua ssl certificate verify error

解决openresty发送https请求时 lua ssl certificate verify error lua ssl certificate verify error: (20: unable to get local issuer certificate)问题。发送请求前需要给lua指定一个受信任的证书。

lua请求:

function _M.http_get(self, url, timeout)
     local http = require "resty.http"
     local httpc = http.new()
 
     timeout = timeout or 30000
     httpc:set_timeout(timeout)
 
     local res, err = httpc:request_uri(url, {
         method = "GET",
         headers = {
             ["Content-Type"] = "application/x-www-form-urlencoded",
       }
     })
     httpc:set_keepalive(5000, 100)
     --httpc:close()
     return res,err
end
 
---example
local weUrl = 'https://api.weixin.qq.com/sns/jscode2session'
local res, _err = _M:http_get(weUrl, 15000)

一、给lua指定证书

# fix lua ssl certificate verify error lua ssl certificate verify error: (20: unable to get local issuer certificate) 
#bash
yum install ca-certificates
update-ca-trust
cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-lua.pem
 
#Nginx.conf
lua_ssl_verify_depth 2;
lua_ssl_trusted_certificate '/etc/ssl/certs/ca-lua.pem';

如何解决openresty lua ssl certificate verify error插图

二、遇到的其他问题解决

#nginx.conf
resolver 223.5.5.5 223.6.6.6 1.2.4.8 114.114.114.114 8.8.8.8 valid=3600s;

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
未整理

直播带货怎么做?商家如何玩转直播带货,针对商家 内容干货 目的赚钱

2021-5-5 0:00:00

未整理

云优YUNUCMS企业网站管理系统

2021-5-7 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索