fix(mailer): make Mua trust the CAStore bundle

Mua (the SMTP adapter in the docs) trusts the OS CA store unless it gets
a CA. Pass the CAStore bundle, but keep a CA that the admin set.
This commit is contained in:
Lain Soykaf 2026-10-22 11:21:50 +04:00
commit accadd99f3
No known key found for this signature in database
3 changed files with 46 additions and 2 deletions

View file

@ -61,4 +61,33 @@ defmodule Pleroma.Emails.MailerTest do
assert hackney_options[:ssl_options] ==
Pleroma.HTTP.TLS.ssl_options()
end
describe "put_mua_cacertfile/1" do
test "makes Mua trust the CAStore bundle" do
config = Mailer.put_mua_cacertfile(adapter: Swoosh.Adapters.Mua, relay: "mail.example.com")
assert config[:ssl] == [cacertfile: CAStore.file_path()]
assert config[:relay] == "mail.example.com"
end
test "keeps other ssl options" do
config = Mailer.put_mua_cacertfile(adapter: Swoosh.Adapters.Mua, ssl: [depth: 3])
assert config[:ssl] == [cacertfile: CAStore.file_path(), depth: 3]
end
test "keeps a CA that the admin set" do
config = [adapter: Swoosh.Adapters.Mua, ssl: [cacertfile: "/etc/ssl/smtp.pem"]]
assert Mailer.put_mua_cacertfile(config) == config
config = [adapter: Swoosh.Adapters.Mua, ssl: [cacerts: []]]
assert Mailer.put_mua_cacertfile(config) == config
end
test "leaves other adapters alone" do
config = [adapter: Swoosh.Adapters.SMTP, relay: "mail.example.com"]
assert Mailer.put_mua_cacertfile(config) == config
end
end
end