使用 openresty (resty.http) 时出现“握手失败”错误

问题描述

我正在尝试使用 openresty 中的 lua 代码调用 HTTPS 上游服务器。代码如下:

local http = require "resty.http"

local M = {}

function M.makeHttpCall()
    local httpc = http.new()
    local res,err = httpc:request_uri("https://<url>",{
        method = "GET",ssl_verify = false
    })
    if not res then
        ngx.status = 500
        ngx.say("Error: ",err)
        return
    end

    .....
end

Nginx.conf有如下相关配置:

server {
        listen 8080;
        resolver local=on ipv6=off;
        .....
        location /httpcall {
            default_type 'application/json';
            content_by_lua_block {
                require("../lua-modules/http")["makeHttpCall"]()
            }
        }

以下错误记录在 error.log 中:

SSL_do_handshake() Failed (SSL: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:SSL alert number 40),client: 127.0.0.1,server:,request: "GET /httpcall HTTP/1.1",host: "localhost:8080"
http.lua:15: makeHttpCall(): **request Failed: handshake Failed**,host: "localhost:8080"

可以成功调用HTTP端点。

请问有什么解决问题的方法吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)