OpenSSL: add remote host info to log line for in-connection TLS error. Bug 3010
authorJeremy Harris <jgh146exb@wizmail.org>
Sat, 15 Jul 2023 15:12:58 +0000 (16:12 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 15 Jul 2023 15:12:58 +0000 (16:12 +0100)
src/src/receive.c
src/src/tls-openssl.c
test/runtest

index 0891a4a8c6ca1909c7ac4273a215d80930c52e61..4271561d7fbe667ab9e4c789b400b3abda8a2f30 100644 (file)
@@ -3911,8 +3911,7 @@ else
       break;
     }
 
-  g = string_append(NULL, 2, US"F=",
-    sender_address[0] == 0 ? US"<>" : sender_address);
+  g = string_append(NULL, 2, US"F=", *sender_address ? sender_address : US"<>");
   g = add_host_info_for_log(g);
 
   log_write(0, LOG_MAIN|LOG_REJECT, "%Y %srejected by local_scan(): %.256s",
@@ -4056,7 +4055,7 @@ g = string_get(256);
 
 g = string_append(g, 2,
   fake_response == FAIL ? US"(= " : US"<= ",
-  sender_address[0] == 0 ? US"<>" : sender_address);
+  *sender_address ? sender_address : US"<>");
 if (message_reference)
   g = string_append(g, 2, US" R=", message_reference);
 
index 22c8ea99ae83bebeddd91ad857ad35e75725474b..2e537a160c05f3e18414bb87bdc4a283ec696ff4 100644 (file)
@@ -4532,10 +4532,15 @@ switch(error)
 
   /* Handle genuine errors */
   case SSL_ERROR_SSL:
+    {
+    uschar * conn_info = smtp_get_connection_info();
+    if (Ustrncmp(conn_info, US"SMTP ", 5) == 0) conn_info += 5;
+    /* I'd like to get separated H= here, but too hard for now */
     ERR_error_string_n(ERR_get_error(), ssl_errstring, sizeof(ssl_errstring));
-    log_write(0, LOG_MAIN, "TLS error (SSL_read): %s", ssl_errstring);
+    log_write(0, LOG_MAIN, "TLS error (SSL_read): on %s %s", conn_info, ssl_errstring);
     ssl_xfer_error = TRUE;
     return FALSE;
+    }
 
   default:
     DEBUG(D_tls) debug_printf("Got SSL error %d\n", error);
index e918b0cdf0abb209ad1580c46982441a1421c1cd..17f7ab4c908434175453be3b82666a00f7f35ea1 100755 (executable)
@@ -1556,7 +1556,7 @@ RESET_AFTER_EXTRA_LINE_READ:
 
     # OpenSSL version variances
     s/(TLS error on connection [^:]*: error:)[0-9A-F]{8}(:system library):(?:fopen|func\(4095\)|):(No such file or directory)$/$1xxxxxxxx$2:fopen:$3/;
-    next if /TLS error \(SSL_read\): error:0A000126:SSL routines::unexpected eof while reading$/ ;
+    next if /TLS error \(SSL_read\): .*error:0A000126:SSL routines::unexpected eof while reading$/ ;
     s/EVDATA: \K\(SSL_accept\): error:0A000126:SSL routines::unexpected eof while reading/SSL_accept: TCP connection closed by peer/;
     s/(DANE attempt failed.*error:)[0-9A-F]{8}(:SSL routines:)(?:(?i)ssl3_get_server_certificate|tls_process_server_certificate|CONNECT_CR_CERT|)(?=:certificate verify failed$)/$1xxxxxxxx$2ssl3_get_server_certificate/;
     s/(DKIM: validation error: )error:[0-9A-F]{8}:rsa routines:(?:(?i)int_rsa_verify|CRYPTO_internal):(?:bad signature|algorithm mismatch)$/$1Public key signature verification has failed./;