dani-garcia / vaultwarden

Unofficial Bitwarden compatible server written in Rust, formerly known as bitwarden_rs
GNU Affero General Public License v3.0
36.78k stars 1.79k forks source link

Error sending SMTP test email LetreErr #917

Closed baahver closed 4 years ago

baahver commented 4 years ago

I'm having trouble with the configuration of smtp. Sending mail was working before. I was using localhost smtp on port 25 without tls ssl. But now unsecure smtp is changed to opportunistc if I understand it well. https://github.com/dani-garcia/bitwarden_rs/pull/901 I used unsecure port 25 because I had problems with setting up tls or ssl.

Now I use: -e SMTP_HOST=smtp.example.com \ -e SMTP_SSL=true \ -e SMTP_PORT=587 \ -e SMTP_FROM=info@example.com \ -e SMTP_USERNAME=info@example.com \ -e SMTP_PASSWORD=<mypassword> \

If I try to send a test mail I get: "Error sending SMTP test email LetreErr" and: tail -fn20 /bw-data/bitwarden.log shows me this: 2020-03-19 12:16:10][request][INFO] POST /admin/test/smtp/ [2020-03-19 12:16:11][lettre::smtp][INFO] connection established to <Serversaddress>:587 [2020-03-19 12:16:11][error][ERROR] LetreErr. [CAUSE] Io( Custom { kind: Other, error: Failure( Ssl( Error { code: ErrorCode( 1, ), cause: Some( Ssl( ErrorStack( [ Error { code: 337047686, library: "SSL routines", function: "tls_process_server_certificate", reason: "certificate verify failed", file: "../ssl/statem/statem_clnt.c", line: 1915, }, ], ), ), ), }, X509VerifyResult { code: 62, error: "Hostname mismatch", }, ), ), }, ) [2020-03-19 12:16:11][response][INFO] POST /admin/test/smtp (test_smtp) => 400 Bad Request

I'm using postfix on Ubuntu server with bitwarden in a docker on Apache2 with proxy installed. All was woring well before. Anyone does have a clue what my problem is here?

dani-garcia commented 4 years ago

Yeah the change to opportunistic TLS has broken a couple of configs before, so I've reverted it for now. In some hours the new builds will be available.

baahver commented 4 years ago

Ok thank you. I will try it later after an update then. It would be better if I managed to activate a ssl/tls connection then. If you have some suggestions on that, that would be great. Thanks a lot Dani-Garcia for all the good work!

baahver commented 4 years ago

Ok. I just pulled the 'new' version. And all is working well now. Stil do not know why smtp over ssl or tls is not working in my system.

dani-garcia commented 4 years ago

As the issue is fixed I'm closing this, about why the certificate isn't working, I'm assuming the certificate provided by the server doesn't match the host name in the config, and that's why you get a "Hostname mismatch" there.