Skip to content

Commit

Permalink
fix(db) allow self-signed certificates in migrations
Browse files Browse the repository at this point in the history
A port of 68d358b to the new DAO, now that it is also used within the
migrations.

See #2908
  • Loading branch information
thibaultcha committed Jul 5, 2018
1 parent 1bdbbae commit fc415d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kong/db/strategies/cassandra/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function CassandraConnector.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 the CLI in order to allow for self-signed
-- certificates to be trusted (via opts.cafile) in the resty-cli
-- interpreter (no way to set lua_ssl_trusted_certificate).
local socket = require "cassandra.socket"
socket.force_luasocket("timer", true)
end

if kong_config.cassandra_username and kong_config.cassandra_password then
Expand Down
3 changes: 3 additions & 0 deletions kong/db/strategies/postgres/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ local setkeepalive
local function connect(config)
local phase = get_phase()
if phase == "init" or phase == "init_worker" or ngx.IS_CLI then
-- Force LuaSocket usage in the CLI in order to allow for self-signed
-- certificates to be trusted (via opts.cafile) in the resty-cli
-- interpreter (no way to set lua_ssl_trusted_certificate).
config.socket_type = "luasocket"

else
Expand Down

0 comments on commit fc415d0

Please sign in to comment.