Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dao) allow self-signed certificates for migrations #2908

Merged
merged 2 commits into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions kong/dao/db/cassandra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ function _M.new(kong_config)
if ngx.IS_CLI then
local policy = require("resty.cassandra.policies.reconnection.const")
cluster_options.reconn_policy = policy.new(100)

-- Force LuaSocket usage in order to allow for self-signed certificates
-- to be trusted (via opts.cafile) in the resty-cli interpreter.
-- As usual, LuaSocket is also forced in non-supported cosocket contexts.
local socket = require "cassandra.socket"
socket.force_luasocket("timer", true)
end

--
Expand Down
12 changes: 10 additions & 2 deletions kong/dao/db/postgres.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ end

local function query_opts(self)
local opts = self:clone_query_options()
opts.socket_type = forced_luasocket_phases[get_phase()] and
"luasocket" or "nginx"

if ngx.IS_CLI or forced_luasocket_phases[get_phase()] then
-- Force LuaSocket usage in order to allow for self-signed certificates
-- to be trusted (via opts.cafile) in the resty-cli interpreter.
-- As usual, LuaSocket is also forced in non-supported cosocket contexts.
opts.socket_type = "luasocket"

else
opts.socket_type = "nginx"
end

return opts
end
Expand Down