Skip to content

Commit

Permalink
support erlang 24
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Jun 11, 2024
1 parent 483b61c commit ab497a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
23 changes: 19 additions & 4 deletions lib/tower_rollbar/rollbar/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ defmodule TowerRollbar.Rollbar.Client do
Jason.encode!(payload)
},
[
ssl: [
verify: :verify_peer,
cacerts: :public_key.cacerts_get()
]
ssl: tls_client_options()
],
[]
) do
Expand All @@ -29,6 +26,24 @@ defmodule TowerRollbar.Rollbar.Client do
end
end

if function_exported?(:public_key, :cacerts_get, 0) do
# Included in Erlang 25+
defp tls_client_options do
[
verify: :verify_peer,
cacerts: :public_key.cacerts_get()
]
end
else
# Support Erlang < 25
defp tls_client_options do
[
verify: :verify_peer,
cacertfile: CAStore.file_path()
]
end
end

defp access_token do
Application.fetch_env!(:tower_rollbar, :access_token)
end
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ defmodule TowerRollbar.MixProject do
[
{:jason, "~> 1.4"},
{:tower, github: "mimiquate/tower"},
{:plug, "~> 1.16"}
{:plug, "~> 1.16"},
{:castore, "~> 1.0"}
]
end

Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%{
"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"plug": {:hex, :plug, "1.16.0", "1d07d50cb9bb05097fdf187b31cf087c7297aafc3fed8299aac79c128a707e47", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbf53aa1f5c4d758a7559c0bd6d59e286c2be0c6a1fac8cc3eee2f638243b93e"},
Expand Down

0 comments on commit ab497a8

Please sign in to comment.