Skip to content

Commit

Permalink
Use apply for optional dynamic cert paths
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Jun 17, 2023
1 parent 7ee360c commit 3891481
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/cldr/http/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -350,22 +350,22 @@ defmodule Cldr.Http do
"/etc/ssl/cert.pem"
]

defp dymanic_certificate_locations do
defp dynamic_certificate_locations do
[
# Configured cacertfile
Application.get_env(:ex_cldr, :cacertfile),

# Populated if hex package CAStore is configured
if(Code.ensure_loaded?(CAStore), do: CAStore.file_path()),
if(Code.ensure_loaded?(CAStore), do: apply(CAStore, :file_path, [])),

# Populated if hex package certfi is configured
if(Code.ensure_loaded?(:certifi), do: :certifi.cacertfile() |> List.to_string())
if(Code.ensure_loaded?(:certifi), do: apply(:certifi, :cacertfile, []) |> List.to_string())
]
|> Enum.reject(&is_nil/1)
end

def certificate_locations() do
dymanic_certificate_locations() ++ @static_certificate_locations
dynamic_certificate_locations() ++ @static_certificate_locations
end

@doc false
Expand Down Expand Up @@ -395,7 +395,7 @@ defmodule Cldr.Http do
be automatically detected after recomilation.
3. Specify the location of a certificate trust store
by configuring it in `config.exs`:
by configuring it in `config.exs` or `runtime.exs`:
config :ex_cldr,
cacertfile: "/path/to/cacertfile",
Expand Down

0 comments on commit 3891481

Please sign in to comment.