Skip to content

Commit b82694b

Browse files
committed
Rely on certificate stores provided by Erlang/OTP 25+
1 parent 67ef8c1 commit b82694b

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.9.0-dev
4+
5+
* Rely on certificate stores provided by Erlang/OTP 25+
6+
37
## v0.8.4 (2024-06-04)
48

59
* Support configuring `make_precompiler_downloader`

Diff for: lib/elixir_make/downloader/httpc.ex

+8-51
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,16 @@ defmodule ElixirMake.Downloader.Httpc do
5050

5151
defp cacerts_options do
5252
cond do
53+
path = System.get_env("HEX_CACERTS_PATH") ->
54+
[cacertfile: path]
55+
5356
path = System.get_env("ELIXIR_MAKE_CACERT") ->
57+
IO.warn("Setting ELIXIR_MAKE_CACERT is deprecated, please set HEX_CACERTS_PATH instead")
5458
[cacertfile: path]
5559

5660
certs = otp_cacerts() ->
5761
[cacerts: certs]
5862

59-
Application.spec(:castore, :vsn) ->
60-
[cacertfile: Application.app_dir(:castore, "priv/cacerts.pem")]
61-
62-
Application.spec(:certifi, :vsn) ->
63-
[cacertfile: Application.app_dir(:certifi, "priv/cacerts.pem")]
64-
65-
path = cacerts_from_os() ->
66-
[cacertfile: path]
67-
6863
true ->
6964
warn_no_cacerts()
7065
[]
@@ -77,65 +72,27 @@ defmodule ElixirMake.Downloader.Httpc do
7772
try do
7873
:public_key.cacerts_get()
7974
rescue
80-
_ ->
81-
nil
75+
_ -> nil
8276
end
8377
end
8478
end
8579

86-
# https_opts and related code are taken from
87-
# https://github.com/elixir-cldr/cldr_utils/blob/v2.19.1/lib/cldr/http/http.ex
88-
@certificate_locations [
89-
# Debian/Ubuntu/Gentoo etc.
90-
"/etc/ssl/certs/ca-certificates.crt",
91-
92-
# Fedora/RHEL 6
93-
"/etc/pki/tls/certs/ca-bundle.crt",
94-
95-
# OpenSUSE
96-
"/etc/ssl/ca-bundle.pem",
97-
98-
# OpenELEC
99-
"/etc/pki/tls/cacert.pem",
100-
101-
# CentOS/RHEL 7
102-
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem",
103-
104-
# Open SSL on MacOS
105-
"/usr/local/etc/openssl/cert.pem",
106-
107-
# MacOS & Alpine Linux
108-
"/etc/ssl/cert.pem"
109-
]
110-
111-
defp cacerts_from_os do
112-
Enum.find(@certificate_locations, &File.exists?/1)
113-
end
114-
11580
defp warn_no_cacerts do
11681
Mix.shell().error("""
11782
No certificate trust store was found.
11883
119-
Tried looking for: #{inspect(@certificate_locations)}
120-
12184
A certificate trust store is required in
12285
order to download locales for your configuration.
12386
Since elixir_make could not detect a system
12487
installed certificate trust store one of the
12588
following actions may be taken:
12689
127-
1. Install the hex package `castore`. It will
128-
be automatically detected after recompilation.
129-
130-
2. Install the hex package `certifi`. It will
131-
be automatically detected after recompilation.
132-
133-
3. Specify the location of a certificate trust store
90+
1. Specify the location of a certificate trust store
13491
by configuring it in environment variable:
13592
136-
export ELIXIR_MAKE_CACERT="/path/to/cacerts.pem"
93+
export HEX_CACERTS_PATH="/path/to/cacerts.pem"
13794
138-
4. Use OTP 25+ on an OS that has built-in certificate
95+
2. Use OTP 25+ on an OS that has built-in certificate
13996
trust store.
14097
""")
14198
end

Diff for: mix.exs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ElixirMake.Mixfile do
22
use Mix.Project
33

4-
@version "0.8.4"
4+
@version "0.9.0-dev"
55
def project do
66
[
77
app: :elixir_make,
@@ -21,8 +21,6 @@ defmodule ElixirMake.Mixfile do
2121

2222
defp deps do
2323
[
24-
{:castore, "~> 0.1 or ~> 1.0", optional: true},
25-
{:certifi, "~> 2.0", optional: true},
2624
{:ex_doc, "~> 0.20", only: :docs}
2725
]
2826
end

0 commit comments

Comments
 (0)