An alternative to reporting an error in the https request of lua in openresty
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.