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: remaining SSL connections that need to set verify_none option #605

Merged
merged 1 commit into from
Feb 21, 2025
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.7
2.3.8
16 changes: 10 additions & 6 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,16 @@ defmodule Supavisor.ClientHandler do
@spec get_secrets(map, String.t()) :: {:ok, {:auth_query, fun()}} | {:error, term()}
def get_secrets(%{user: user, tenant: tenant}, db_user) do
ssl_opts =
if tenant.upstream_ssl and tenant.upstream_verify == "peer" do
if tenant.upstream_ssl and tenant.upstream_verify == :peer do
[
{:verify, :verify_peer},
{:cacerts, [Helpers.upstream_cert(tenant.upstream_tls_ca)]},
{:server_name_indication, String.to_charlist(tenant.db_host)},
{:customize_hostname_check, [{:match_fun, fn _, _ -> true end}]}
verify: :verify_peer,
cacerts: [Helpers.upstream_cert(tenant.upstream_tls_ca)],
server_name_indication: String.to_charlist(tenant.db_host),
customize_hostname_check: [{:match_fun, fn _, _ -> true end}]
]
else
[
verify: :verify_none
]
end

Expand All @@ -890,7 +894,7 @@ defmodule Supavisor.ClientHandler do
],
queue_target: 1_000,
queue_interval: 5_000,
ssl_opts: ssl_opts || []
ssl_opts: ssl_opts
)

try do
Expand Down
14 changes: 9 additions & 5 deletions lib/supavisor/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ defmodule Supavisor.Helpers do
ssl_opts =
if upstream_ssl? and params["upstream_verify"] == "peer" do
[
{:verify, :verify_peer},
{:cacerts, [upstream_cert(params["upstream_tls_ca"])]},
{:server_name_indication, String.to_charlist(params["db_host"])},
{:customize_hostname_check, [{:match_fun, fn _, _ -> true end}]}
verify: :verify_peer,
cacerts: [upstream_cert(params["upstream_tls_ca"])],
server_name_indication: String.to_charlist(params["db_host"]),
customize_hostname_check: [{:match_fun, fn _, _ -> true end}]
]
else
[
verify: :verify_none
]
end

Expand All @@ -50,7 +54,7 @@ defmodule Supavisor.Helpers do
],
queue_target: 1_000,
queue_interval: 5_000,
ssl_opts: ssl_opts || []
ssl_opts: ssl_opts
)

check =
Expand Down
16 changes: 10 additions & 6 deletions lib/supavisor/secret_checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ defmodule Supavisor.SecretChecker do

def handle_continue(:init_conn, %{auth: auth} = state) do
ssl_opts =
if auth.upstream_ssl and auth.upstream_verify == "peer" do
if auth.upstream_ssl and auth.upstream_verify == :peer do
[
{:verify, :verify_peer},
{:cacerts, [Helpers.upstream_cert(auth.upstream_tls_ca)]},
{:server_name_indication, auth.host},
{:customize_hostname_check, [{:match_fun, fn _, _ -> true end}]}
verify: :verify_peer,
cacerts: [Helpers.upstream_cert(auth.upstream_tls_ca)],
server_name_indication: auth.host,
customize_hostname_check: [{:match_fun, fn _, _ -> true end}]
]
else
[
verify: :verify_none
]
end

Expand All @@ -59,7 +63,7 @@ defmodule Supavisor.SecretChecker do
],
queue_target: 1_000,
queue_interval: 5_000,
ssl_opts: ssl_opts || []
ssl_opts: ssl_opts
)

# kill the postgrex connection if the current process exits unexpectedly
Expand Down
Loading