From 31d7cc9a9c4232a3184763e898330c8b2c5cc63d Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 4 Aug 2023 23:51:15 +0100 Subject: [PATCH] Allow Pleroma.HTTP to connect to raw-HTTP without freaking mint out --- lib/pleroma/application.ex | 1 - lib/pleroma/http.ex | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 7d174cca4..db49ccfae 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -269,7 +269,6 @@ defp http_children do |> Config.get([]) |> Pleroma.HTTP.AdapterHelper.add_pool_size(pool_size) |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy_pool(proxy) - |> Pleroma.HTTP.AdapterHelper.maybe_add_cacerts(:public_key.cacerts_get()) |> Keyword.put(:name, MyFinch) [{Finch, config}] diff --git a/lib/pleroma/http.ex b/lib/pleroma/http.ex index 5ef7b188d..9346ffa16 100644 --- a/lib/pleroma/http.ex +++ b/lib/pleroma/http.ex @@ -62,6 +62,13 @@ def request(method, url, body, headers, options) when is_binary(url) do uri = URI.parse(url) adapter_opts = AdapterHelper.options(uri, options || []) + adapter_opts = + if uri.scheme == :https do + AdapterHelper.maybe_add_cacerts(adapter_opts, :public_key.cacerts_get()) + else + adapter_opts + end + options = put_in(options[:adapter], adapter_opts) params = options[:params] || [] request = build_request(method, headers, options, url, body, params)