Skip to content

Commit

Permalink
fix(electric): Skip loading cacerts (#1407)
Browse files Browse the repository at this point in the history
Merging #1370 into `main`
inadvertently broke the fix that had been introduced in
#1396. That latter PR's
description goes into detail about why we are not ready to validate
server certificates.
  • Loading branch information
alco committed Jun 27, 2024
1 parent febb710 commit 0f11eb2
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions components/electric/lib/electric/replication/postgres_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,31 @@ defmodule Electric.Replication.PostgresConnectorMng do
#
# As explained in https://github.com/erlang/otp/issues/8604, the function spec of
# `:public_key.cacerts_load()` is incorrect.
@dialyzer {:nowarn_function, load_cacerts: 0}

defp load_cacerts do
case :public_key.cacerts_load() do
:ok ->
cacerts = :public_key.cacerts_get()
Logger.info("Successfully loaded #{length(cacerts)} cacerts from the OS")
{:ok, cacerts}

{:error, reason} ->
Logger.warning("Failed to load cacerts from the OS: #{inspect(reason)}")
:error

:undefined ->
Logger.warning("Failed to load cacerts from the OS.")
:error
#
# ssl_verify_opts also needs to have its warnings ignored due to the hacky nature of below
# code.
@dialyzer {:nowarn_function, load_cacerts: 0, ssl_verify_opts: 0}

defp load_cacerts, do: :error

# Skip loading cacerts because managed database providers tend to have certificate issues
# that we haven't yet decided how to deal with.
if false do
defp load_cacerts do
case :public_key.cacerts_load() do
:ok ->
cacerts = :public_key.cacerts_get()
Logger.info("Successfully loaded #{length(cacerts)} cacerts from the OS")
{:ok, cacerts}

{:error, reason} ->
Logger.warning("Failed to load cacerts from the OS: #{inspect(reason)}")
:error

:undefined ->
Logger.warning("Failed to load cacerts from the OS.")
:error
end
end
end

Expand Down

0 comments on commit 0f11eb2

Please sign in to comment.