Skip to content

Commit a201220

Browse files
committed
Fix elasticsearch connections over SSL.
1 parent dcaa544 commit a201220

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/api-umbrella/utils/elasticsearch.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ function _M.query(path, options)
3333
end
3434

3535
local connect_ok, connect_err = httpc:connect(server["host"], server["port"])
36-
if connect_err then
36+
if not connect_ok then
3737
httpc:close()
3838
return nil, "elasticsearch connect error: " .. (connect_err or "")
3939
end
4040

41+
if server["scheme"] == "https" then
42+
local ssl_ok, ssl_err = httpc:ssl_handshake(nil, server["host"], true)
43+
if not ssl_ok then
44+
httpc:close()
45+
return nil, "elasticsearch ssl handshake error: " .. (ssl_err or "")
46+
end
47+
end
48+
4149
local res, err = httpc:request(options)
4250
if err then
4351
httpc:close()
@@ -49,6 +57,7 @@ function _M.query(path, options)
4957
httpc:close()
5058
return nil, "elasticsearch read body error: " .. (body_err or "")
5159
end
60+
res["body"] = body
5261

5362
local keepalive_ok, keepalive_err = httpc:set_keepalive()
5463
if not keepalive_ok then

0 commit comments

Comments
 (0)