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

Check whether CAStore is available in compile-time #428

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
9 changes: 7 additions & 2 deletions lib/mint/core/transport/ssl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,12 @@ defmodule Mint.Core.Transport.SSL do
defp blocked_cipher?({kex, cipher, _mac, prf}), do: blocked_cipher?({kex, cipher, prf})
defp blocked_cipher?({_kex, _cipher, _prf} = suite), do: suite in @blocked_ciphers

defp raise_on_missing_castore! do
Code.ensure_loaded?(CAStore) ||
if Code.ensure_loaded?(CAStore) do
defp raise_on_missing_castore! do
:ok
end
else
defp raise_on_missing_castore! do
raise """
default CA trust store not available; please add `:castore` to your project's \
dependencies or specify the trust store using the :cacertfile/:cacerts option \
Expand All @@ -714,6 +718,7 @@ defmodule Mint.Core.Transport.SSL do

See: https://www.erlang.org/blog/my-otp-25-highlights/#ca-certificates-can-be-fetched-from-the-os-standard-place
"""
end
end

defp wrap_err({:error, reason}), do: {:error, wrap_error(reason)}
Expand Down
Loading