-
Notifications
You must be signed in to change notification settings - Fork 186
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
Add email.tlsname config option #17849
base: develop
Are you sure you want to change the base?
Conversation
The existing `email.smtp_host` config option is used for two distinct purposes: it is resolved into the IP address to connect to, and used to (request via SNI and) validate the server's certificate if TLS is enabled. This new option allows specifying a different name for the second purpose. This is especially helpful, if `email.smtp_host` isn't a global FQDN, but something that resolves only locally (e.g. "localhost" to connect through the loopback interface, or some other internally routed name), that one cannot get a valid certificate for.
9cc3545
to
685f746
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable on face value.
Have you tested to make sure this works?
I did test it in one configuration ( The I did not touch the branch for Twisted < v21. Should I try to implement this for old Twisted versions as well? That would basically entail backporting the |
@@ -117,10 +122,10 @@ def build_sender_factory(**kwargs: Any) -> ESMTPSenderFactory: | |||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not touch the branch for Twisted < v21. Should I try to implement this for old Twisted versions as well? That would basically entail backporting the
hostname
parameter introduced in Twisted v21 into our_NoTLSESMTPSender
class, where that class would also need to close over thetlsname
parameter, as it's value isn't provided through the v21ESTMPSenderFactory
. I don't have a system with old Twisted readily available to test that such an implementation.
Or maybe just log an error and refuse to send mail if Twisted < v21 andtlsname != smtphost
?
Thanks for bringing this up!
If we're not going to support this option for Twisted < v21, it would be ideal fail early and not start up at all (error when parsing the config). Along with updating the documentation to state the version requirement. But I'm not sure of another spot where we make a similar constraint. Perhaps it's important that we support Twisted < v21 but I don't have that context.
I also don't have a sense for how big or complex the hostname
backport would be but seems like it's do-able to you.
I don't have a system with old Twisted readily available to test that such an implementation.
It looks like the trial-olddeps
CI job uses the minimum versions from our pyproject.toml
which will be Twisted 18.9.0. So as long as we have some tests for this new functionality in tests/handlers/test_send_email.py
, we should be covered.
I can run the CI when you want but should be also possible emulate the same thing that the CI job is doing to test it locally as well.
The existing
email.smtp_host
config option is used for two distinct purposes: it is resolved into the IP address to connect to, and used to (request via SNI and) validate the server's certificate if TLS is enabled. This new option allows specifying a different name for the second purpose.This is especially helpful, if
email.smtp_host
isn't a global FQDN, but something that resolves only locally (e.g. "localhost" to connect through the loopback interface, or some other internally routed name), that one cannot get a valid certificate for.Alternatives would of course be to specify a global FQDN as
email.smtp_host
, or to disable TLS entirely, both of which might be undesirable, depending on the SMTP server configuration.Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)