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

Adding an smtp ca certs setting #1486

Closed
wants to merge 2 commits into from
Closed

Adding an smtp ca certs setting #1486

wants to merge 2 commits into from

Conversation

kyzh
Copy link

@kyzh kyzh commented Apr 10, 2017

In order to get TLS peer verification working on my gandi.net SMTP settings, I need certificate from trusted Certificate Authorities to verify the server.
This change aim at configuring action mailer to use a default ca certificates file.
The second commit makes the change configurable via the .env file facility

I used the provided docker-compose containers and run into problem since 1.1.1 to send emails out.
I investigated and found the verification to be broken.
The default certificate authority certificate seems to dictated by ruby "OpenSSL::X509::DEFAULT_CERT_FILE"

root@masto:~# docker exec -ti mastodon_web_1 sh
/mastodon # ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
/etc/ssl/cert.pem

The main issue is that it doesn't exists:

mastodon@masto:~$ docker exec -it mastodon_web_1 sh
/mastodon # file /etc/ssl/cert.pem
/etc/ssl/cert.pem: cannot open `/etc/ssl/cert.pem' (No such file or directory)

With this change, I was able to send emails again.

Florentin Raud added 2 commits April 11, 2017 00:22
In order to get TLS peer verification working on my gandi.net SMTP settings, I need certificate from trusted Certificate Authorities to verify the server.
This change aim at configuring action mailer to use a default ca certificates file.

I use the provided docker-compose containers.
The default certificate authority certificate seems to dictated by ruby "OpenSSL::X509::DEFAULT_CERT_FILE"
```
root@masto:~# docker exec -ti mastodon_web_1 sh
/mastodon # ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
/etc/ssl/cert.pem
```
The main issue is that it doesn't exists:
```
mastodon@masto:~$ docker exec -it mastodon_web_1 sh
/mastodon # file /etc/ssl/cert.pem
/etc/ssl/cert.pem: cannot open `/etc/ssl/cert.pem' (No such file or directory)
```
This brings the ca cert choice up to the user in case /etc/ssl/certs/ca-certificates.crt is not suitable.
Copy link

@ToroNZ ToroNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this and works as expected. Thanks

@kyzh kyzh mentioned this pull request Apr 11, 2017
1 task
@@ -102,6 +102,7 @@
:authentication => ENV['SMTP_AUTH_METHOD'] || :plain,
:openssl_verify_mode => ENV['SMTP_OPENSSL_VERIFY_MODE'] || 'peer',
:enable_starttls_auto => ENV['SMTP_ENABLE_STARTTLS_AUTO'] || true,
:ca_file => ENV['SMTP_SSL_CERT_FILE'] || "/etc/ssl/certs/ca-certificates.crt",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this latter value is a standard location we can rely on.

This might be a fix for some servers ... but I think a better improvement here would be to improve the documentation to show how ruby can be set up with correct CA certs, instead of having what is basically a work-around as the standard approach.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I would remove the or and, if not set, leave it empty.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more than one way to fix this issue.
We could add the env variable in the docker file and not provide a default value in the production.rb
That way we only fix the one use case (docker containers) we have proper control over.
I can change the PR to reflect this is it is the consensus.

@Wonderfall
Copy link
Contributor

It works, thanks.

@kyzh
Copy link
Author

kyzh commented Apr 11, 2017

Happy to close as #1563 provides a solution to people not being able to send email.
I will create an issue to try to get SMTP best practise agreed on and do PR on that

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 this pull request may close these issues.

None yet

5 participants