微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用 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 举报,一经查实,本站将立刻删除。