我用的是这个 https://github.com/pintsized/lua-resty-http
我有一些旧的php代码, 需要转到 openresty.
$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, "https://www.xxxx.com");
curl_setopt($tuCurl, CURLOPT_PORT , 443);
curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($tuCurl, CURLOPT_SSLCERT, 'test.pem');
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tuCurl, CURLOPT_SSLKEY, 'test.key');
我在nginx配置文件里
lua_ssl_trusted_certificate test.pem;
lua 代码
local httpc = http.new()
local res, err = httpc:request_uri("https://www.xxx.com", {
method = "GET",
})
if not res then
ngx.say("failed to request: ", err)
return
end
ngx.say(res.body)
报错 failed to request: handshake failed
请问是什么原因了
还有一个key文件我不知道在哪设置