]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-client-connection - If SSL connection gets lost, log the last SSL...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 14 Jul 2018 11:16:05 +0000 (13:16 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 24 Aug 2020 07:20:17 +0000 (07:20 +0000)
src/lib-smtp/smtp-client-connection.c

index d79c9fa3c90c3de26d1c6c492978933e7966c652..7ac106d2ec4da0d61f4235d4509d6809e26e09e8 100644 (file)
@@ -329,6 +329,29 @@ smtp_client_connection_lost(struct smtp_client_connection *conn,
                        user_error);
        }
 
+       if (conn->ssl_iostream != NULL) {
+               const char *sslerr =
+                       ssl_iostream_get_last_error(conn->ssl_iostream);
+
+               if (error != NULL && sslerr != NULL) {
+                       error = t_strdup_printf("%s (last SSL error: %s)",
+                                               error, sslerr);
+               } else if (sslerr != NULL) {
+                       error = t_strdup_printf(
+                               "Connection lost (last SSL error: %s)", sslerr);
+               }
+               if (ssl_iostream_has_handshake_failed(conn->ssl_iostream)) {
+                       /* This isn't really a "connection lost", but that we
+                          don't trust the remote's SSL certificate. */
+                       i_assert(error != NULL);
+                       e_error(conn->event, "%s", error);
+                       smtp_client_connection_fail(
+                               conn, SMTP_CLIENT_COMMAND_ERROR_CONNECT_FAILED,
+                               user_error);
+                       return;
+               }
+       }
+
        if (error != NULL)
                e_error(conn->event, "%s", error);
        smtp_client_connection_fail(