Skip to content

Commit 4634d08

Browse files
rorymckinleystuartc
authored andcommitted
Update Swoosh TLS configuration for OTP26+
- swoosh/swoosh#785
1 parent 87541e3 commit 4634d08

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ and this project adheres to
2828

2929
### Fixed
3030

31+
- Since OTP26, if `SMTP_PROVIDER` is set to `smtp` and `SMTP_TLS` is set to
32+
`true` or `if_available` this would result in TLS-related failures when trying
33+
to send emails. This is now fixed for a limited number of use cases (see
34+
(DEPLOYMENT.md)[https://github.com/OpenFn/lightning/blob/main/DEPLOYMENT.md#mail]
35+
for details). [#4602](https://github.com/OpenFn/lightning/issues/4602)
36+
3137
## [2.16.1] - 2026-04-07
3238

3339
## [2.16.1-pre1] - 2026-04-04

DEPLOYMENT.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ variable to one of the following:
142142
You will also want to set the `EMAIL_ADMIN` environment variable to the email
143143
address that will be used as the sender for system emails.
144144

145+
If you are planning on using the `smtp` provider, with `TLS` enabled, the
146+
current implementation has the following contraints:
147+
148+
- Only TLS 1.3 is supported.
149+
- For the purposes of Server Name Indication (SNI), the hostname provided as the
150+
`SMTP_RELAY` is used. This means that the `SMTP_RELAY` value must be present
151+
in a SAN `dNSName` on the cert. Practically, this means that TLS is unlikely
152+
to work if an IP address, or an internal-only hostname is provided as the
153+
`SMTP_RELAY` value.
154+
145155
#### Mailgun
146156

147157
For mailgun, the following environment variables are required:

lib/lightning/config/bootstrap.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ defmodule Lightning.Config.Bootstrap do
389389
end,
390390
:always
391391
),
392+
tls_options: [
393+
versions: [:"tlsv1.3"],
394+
verify: :verify_peer,
395+
cacerts: :public_key.cacerts_get(),
396+
server_name_indication: env!("SMTP_RELAY", :string) |> to_charlist(),
397+
depth: 5,
398+
customize_hostname_check: [
399+
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
400+
]
401+
],
392402
port: env!("SMTP_PORT", :integer, 587)
393403

394404
unknown ->

test/lightning/config/bootstrap_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,16 @@ defmodule Lightning.Config.BootstrapTest do
411411
password: "bar",
412412
relay: "baz",
413413
tls: :always,
414+
tls_options: [
415+
versions: [:"tlsv1.3"],
416+
verify: :verify_peer,
417+
cacerts: :public_key.cacerts_get(),
418+
server_name_indication: to_charlist("baz"),
419+
depth: 5,
420+
customize_hostname_check: [
421+
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
422+
]
423+
],
414424
port: 587
415425
]
416426
end

0 commit comments

Comments
 (0)