Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An alternative to reporting an error in the https request of lua in openresty

2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

There is a set of methods for requesting http/https in openresty: resty.http. The certificate file crt needs to be added for the https request, but I have been trying for a long time. All the certificate files under centos have been tried, and the certificate corresponding to the pin api.dingtalk.com cannot be found. It also reported a missing ssl module.

The normal result can be obtained by using curl request, so there is a bad idea.

Url = "https://oapi.dingtalk.com/gettoken?appkey="..appkey.."&appsecret="..appsecret

Cmd = "echo curl-s\" .url.. "\"

T = io.popen (cmd)

, d = string.find (t:read (),'{"errcode": 0, "access_token": "(% S+)", "errmsg')

Haha, doesn't it look weird? Lua invokes the command line, then captures the return information, and parses it with rules.

There is really no way, the certificate of this problem has been stuck for a long time, so now has not been solved, so using this method, but also perfectly avoid some of the lack of dependency in resty.

★ note that curl cannot be called directly here, because the returned value throws some process information and gets a pile of unparsed garbled code, which must be masked with echo before it can be regularized.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 239

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report