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

Setting enable_starttls_auto to false will not work with Ruby 3 #1434

Closed
ibalosh opened this issue Mar 17, 2021 · 5 comments
Closed

Setting enable_starttls_auto to false will not work with Ruby 3 #1434

ibalosh opened this issue Mar 17, 2021 · 5 comments
Milestone

Comments

@ibalosh
Copy link

ibalosh commented Mar 17, 2021

In SMTP class, there is a setting :enable_starttls_auto which can be true or false. By default this setting is true.

In Ruby 2.x, starttls is false, in Ruby 3 :auto.

The problem is that in delivery_methods smtp file , in method build_smtp_session there is no way to disable starttls, rather there is just a check to enable it, so starttls is always set to auto or true.

@jeremy
Copy link
Collaborator

jeremy commented Mar 17, 2021

Ha good point! 😂

@jeremy
Copy link
Collaborator

jeremy commented Mar 17, 2021

Fixed by #1435, targeting Mail 2.8.0 since it subtly changes config behavior.

@jeremy jeremy closed this as completed Mar 17, 2021
@ibalosh
Copy link
Author

ibalosh commented Mar 22, 2021

tx!

@ktimothy
Copy link

Any updates on this? The PR seems to be abandoned.

@firien
Copy link

firien commented Jul 14, 2021

FWIW: I have been using the following patch/hack as a workaround.

module SMTPFix
  def initialize(address, port = nil)
    super
    @starttls = false
  end
end

Net::SMTP.prepend SMTPFix

@eval eval mentioned this issue Jan 18, 2023
bygf pushed a commit to bygf/charts-gitlab that referenced this issue Apr 14, 2023
This commit fixes mail sending when TLS is disabled. In Ruby 3.0.5,
net-smtp v0.2.1 enabled TLS by default if the server advertises
STARTTLS support. However, mail v2.7.1 didn't explicitly disable TLS
(mikel/mail#1434), so TLS may be used with
Ruby 3 even if it is disabled. mail v2.8.1 has since fixed this issue
via mikel/mail#1480.

However, mail v2.8.1 has a bug in the logic for retrieving the settings
(https://github.com/mikel/mail/blob/2.8.1/lib/mail/network/delivery_methods/smtp.rb#L114):

```
tls = settings[:tls] || settings[:ssl]
```

If `settings[:tls]` is `false` and `settings[:ssl]` is `nil`, then
the result of `false || nil` is `nil`.

This means that TLS cannot be disabled if `settings[:tls]` is set to
`false`.

To fix this, just add a redundant `ssl` config parameter.

This came out of https://gitlab.com/gitlab-org/gitlab/-/issues/399241.

Changelog: fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants