-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Synapse uses TLS1.0 for smtp which is rejected by some mail servers #6211
Comments
After some more testing, this appears to be an issue with Synapse (or rather Twisted) not using an up-to-date TLS protocol when communicating with the mail server. My server is set to not accept TLSv1 or SSLv2 & 3, which explains the |
I second this - seeing exactly the same issue. Interestingly, require_transport_security doesn't seem to do anything. When set to true or false it still attemps STARTTLS which is obviously wrong. |
I am experiencing the exact same issue. |
same here. |
Yes, I have the same behavior here as well. |
While looking at this bug w/ @henry-nicolas yesterday, we did some testing which might be helpful in pinpointing the bug:
|
+1 |
same problem here. I am running Plesk which controls Postfix/Dovecot. The systems are configured to only use TLS 1.2 or higher the log output:
hopefully it belongs to this issue. Some releases before everything worked fine |
i was able to validate that its a TLS problem. i re-enabled old TLS 1.0 and 1.1 to test: that makes it work directly after enabling TLS 1.0 |
Same here on ubuntu server 18.04. Please provide a solution.
|
the problem was that twisted mail smtp wrapper does not call SSL connect at all (inside synapse virtual env > /twisted/mail/smtp.py)
|
It seems that @sbiberhofer is right with the hardcoded part. At any rate, commenting line 2038 in the smtp module where the method gets overwritten to TLSv1 worked for me. I have created a ticket on twisted's issue tracker, that you can find here. |
For what is worth, here is a temporary fix on our side, thank you so much for pinpointing the actual culprit in Twisted sources: https://forge.tedomum.net/tedomum/synapse/blob/aac748e3720e001a2fc9e42ef2add49ce815443e/docker/Dockerfile#L57 If required, I can PR this ugly jewel. |
Since I don't see it mentioned here, here's the ticket on Twisted's side for tracking: https://twistedmatrix.com/trac/ticket/9740 |
Submitted a patch to Twisted. If it's not accepted we can make Synapse use |
The problem seems to be fixed. Could you update the dependency or is it more complicated to get the fix into 1.12.4 maybe? |
@n3m3s1s The fix is not yet in a release version of Twisted. After they've done their next release it should just be a matter of ensuring the version of Twisted used is the latest. |
@clokep Right, sorry. Got a little confused by the 1k branches they have. Looking forward to their next release. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@Neustradamus Please don't harass people. The Twisted devs already answered your question on Twitter (https://twitter.com/twistedmatrix/status/1256852143425773568) giving you a viable solution if you really can't wait for a release (https://twitter.com/twistedmatrix/status/1256852515586338816), this should be more than enough while waiting for them to release a new version. To reiterate and elaborate a bit on the advice the Twisted devs gave, here's how you install the patch if you really really really can't wait for a release: # Activate Synapse's virtualenv
source env/bin/activate
# Uninstall the mainline version of twisted[tls]
pip uninstall twisted[tls]
# Reinstall twisted[tls] from github at the commit provided by the Twisted folks
pip install https://github.com/twisted/twisted/archive/8c251edc95b48d578660343c5de072691ff75e8b.zip#egg=twisted[tls] Let me just empathise that this isn't a recommended procedure as unreleased patches are known to be less stable than releases. Note that you'll need to run |
This should be fixed if you update Twisted to the newly released version (21.2.0). I'm going to close this issue and unlock it. If you upgrade and are still seeing this issue we can re-open and see if Synapse needs any changes. |
So the Client ist synapse and the Server is my Mailserver? |
I don't know how the system is configured. AFAIK, the original error was "unsupported protocol" I think that the "tlsv1 alert unknown ca" is not related to this ticket. Cheers |
well, Matrix can't send E-Mails to my Mailserver, but everything else can. I don't think it is a problem with my Mailserver. |
Ok, my problem was the cert of the Mailserver. Didn't have full chain there, never mind. |
see also #9566 |
Hi, I have the same issue on my homeserver, version 1.40.0. Every mail for new user or password reset fails with the error "cannot connect to server". I guess this is related to my version of twisted being 20.3.0. But how can I upgrade the Twisted version to the right one ? I tried a "pid install -U twisted" but it seems to break my matrix instance, I get the following error when launching synapse:
as related to YunoHost-Apps/synapse_ynh#247, the version for twisted is forced to 20.3.0 ? So how can I resolve this issues without upgrading Twisted ? I am a bit lost 😞 |
sounds like you have another package in your virtualenv which breaks with newer Twisted. Try sharing the whole stacktrace so we can see which it is. |
You have to remove a line from smtp.py. See twisted/twisted@d427cbd If Twisted is updated, treq has to be updated too. That's probably where the "cannot import name '_PY3'" error message comes from. Welcome to the wonderful world of Python and non-existing backward compatibility. |
yes, because using a private interface in another library, and then being surprised when that private interface is removed, could never happen in any other language. |
It just happens in Python much more often then in any other language. I still have a copy of van Rossums "Internet Programming with Python" where he lies on page 5: "New versions of the interpreter will always run programs written for old versions of the interpreter". The packages are an even bigger mess. But never mind. We've mostly completed our migration from Matrix to Mattermost. |
Hi @richvdh , thanks for the reply !
|
twisted is used in matrix-synapse for smtp handling. Mostly this is used for password resets, but also notifications are delivered that way. older versions of twisted require the e-mail server to have TLS1.0 enabled. Obviously, quite a lot of servers have this disabled which means synapse won't be able to deliver mails using such servers. matrix-synapse issue: matrix-org/synapse#6211
twisted is used in matrix-synapse for smtp handling. Mostly this is used for password resets, but also notifications are delivered that way. older versions of twisted require the e-mail server to have TLS1.0 enabled. Obviously, quite a lot of servers have this disabled which means synapse won't be able to deliver mails using such servers. matrix-synapse issue: matrix-org/synapse#6211
it still does not work for my. on my server i always get, no matter what i configure.
the log /var/log/matrix-synapse/homeserver.log
i checked CA cert which is fine. All things with mail clients work properly, like thunderbird or roundcube or other services which connect to the mail server from exernal or localhost my mail server only supports TLS 1.2 and TLS 1.3. SSLv2/v3 is completely disabled for smtp/smtpd. i updated twisted[tls] und removed the older apt package too python3-twisted also tried synapse connecting to mail server locally or by public mail server address any idea what to do? some infos:
some more stuff i tried which also looks good, but without solving or modifying the problem:
|
i recognized it seems to belong to #9599 too. same behaviour: openssl s_client -connect matrix..de:443 |
Description
Requesting a password reset from a brand-new Synapse installation returns a 500 error, with the error
twisted.mail._except.SMTPConnectError: Unable to connect to server.
Steps to reproduce
homeserver.yaml
:After the last step, the server will respond with a 500 error, and the following will be displayed in synapse's log:
And this is displayed in the postfix log of the receiving server:
I've tested this configuration with both
require_transport_security: false
andrequire_transport_security: true
. Also worth mentioning that the username / password are correct, as logging into the mail server from a mail program and sending a test email from there works fine.Version information
New personal homeserver running synapse.
Version: 1.4.0
Install method: Package Manager
The text was updated successfully, but these errors were encountered: