Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make tls_client configuration work in target.smtp block, fixes foxcpp/maddy#688 #760

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/target/smtp/smtp_downstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Downstream struct {
hostname string
endpoints []config.Endpoint
saslFactory saslClientFactory
tlsConfig tls.Config
tlsConfig *tls.Config

connectTimeout time.Duration
commandTimeout time.Duration
Expand Down Expand Up @@ -121,7 +121,7 @@ func (u *Downstream) Init(cfg *config.Map) error {
return nil, nil
}, saslAuthDirective, &u.saslFactory)
cfg.Custom("tls_client", true, false, func() (interface{}, error) {
return tls.Config{}, nil
return &tls.Config{}, nil
}, tls2.TLSClientBlock, &u.tlsConfig)
cfg.Duration("connect_timeout", false, false, 5*time.Minute, &u.connectTimeout)
cfg.Duration("command_timeout", false, false, 5*time.Minute, &u.commandTimeout)
Expand Down Expand Up @@ -229,9 +229,9 @@ func (d *delivery) connect(ctx context.Context) error {
for _, endp := range d.u.endpoints {
var err error
if d.u.lmtp {
_, err = conn.ConnectLMTP(ctx, endp, d.u.starttls, &d.u.tlsConfig)
_, err = conn.ConnectLMTP(ctx, endp, d.u.starttls, d.u.tlsConfig)
} else {
_, err = conn.Connect(ctx, endp, d.u.starttls, &d.u.tlsConfig)
_, err = conn.Connect(ctx, endp, d.u.starttls, d.u.tlsConfig)
}
if err != nil {
if len(d.u.endpoints) != 1 {
Expand Down
2 changes: 1 addition & 1 deletion internal/target/smtp/smtp_downstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestDownstreamDelivery_StartTLS(t *testing.T) {
Port: testPort,
},
},
tlsConfig: *clientCfg.Clone(),
tlsConfig: clientCfg.Clone(),
starttls: true,
log: testutils.Logger(t, "target.smtp"),
}
Expand Down
Loading