Skip to content
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 new option tls_ignore_missing_close_notify #94

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/doc-txt/OptionLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ tls_certificate string* unset main
tls_dh_max_bits integer 2236 main 4.80
tls_dh_min_bits integer 1024 smtp 4.82
tls_dhparam string* unset main 3.20
tls_ignore_missing_close_notify boolean true main (todo git master)
tls_ocsp_file string* unset main 4.80 if experimental_ocsp
tls_on_connect_ports string unset main 4.43
tls_privatekey string* unset main 3.20
Expand Down
1 change: 1 addition & 0 deletions src/src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ bit-count as "NORMAL" (2432) and Thunderbird dropping connection. */
int tls_dh_max_bits = 2236;
uschar *tls_dhparam = NULL;
uschar *tls_eccurve = US"auto";
BOOL tls_ignore_missing_close_notify = TRUE;
# ifndef DISABLE_OCSP
uschar *tls_ocsp_file = NULL;
# endif
Expand Down
1 change: 1 addition & 0 deletions src/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ extern uschar *tls_crl; /* CRL File */
extern int tls_dh_max_bits; /* don't accept higher lib suggestions */
extern uschar *tls_dhparam; /* DH param file */
extern uschar *tls_eccurve; /* EC curve */
extern BOOL tls_ignore_missing_close_notify; /* For semi-broken TLS servers like Gmail and Yandex */
# ifndef DISABLE_OCSP
extern uschar *tls_ocsp_file; /* OCSP stapling proof file */
# endif
Expand Down
1 change: 1 addition & 0 deletions src/src/readconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static optionlist optionlist_config[] = {
{ "tls_dh_max_bits", opt_int, {&tls_dh_max_bits} },
{ "tls_dhparam", opt_stringptr, {&tls_dhparam} },
{ "tls_eccurve", opt_stringptr, {&tls_eccurve} },
{ "tls_ignore_missing_close_notify", opt_bool, {&tls_ignore_missing_close_notify} },
# ifndef DISABLE_OCSP
{ "tls_ocsp_file", opt_stringptr, {&tls_ocsp_file} },
# endif
Expand Down
14 changes: 10 additions & 4 deletions src/src/tls-gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4034,14 +4034,20 @@ do
while (inbytes == GNUTLS_E_AGAIN);

if (inbytes > 0) return inbytes;
if (inbytes == 0)
if (inbytes == 0
// there is a "bug" in Gmail and Yandex servers where they do not send the tls-protocol-mandated `close_notify` on connection close.
// They do it intentionally to save time (skip a roundtrip), but it is against tls-protocol and does spam the exim4 errorlogs like
// 2024-10-12 09:22:27 1szVWE-0071qn-2C H=gmail-smtp-in.l.google.com [142.250.102.27] TLS error on connection (recv_tls_read): The TLS connection was non-properly terminated.
// optionally treat this as a normal EOF.
// This is equivalent to OpenSSL's SSL_OP_IGNORE_UNEXPECTED_EOF flag.
|| (tls_ignore_missing_close_notify && inbytes == GNUTLS_E_PREMATURE_TERMINATION))
{
DEBUG(D_tls) debug_printf("Got TLS_EOF\n");
DEBUG(D_tls) debug_printf("Got TLS_EOF\n");
}
else
{
DEBUG(D_tls) debug_printf("%s: err from gnutls_record_recv\n", __FUNCTION__);
record_io_error(state, (int)inbytes, US"recv", NULL);
DEBUG(D_tls) debug_printf("%s: err from gnutls_record_recv\n", __FUNCTION__);
record_io_error(state, (int)inbytes, US"recv", NULL);
}

return -1;
Expand Down
6 changes: 6 additions & 0 deletions src/src/tls-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2954,6 +2954,12 @@ if (init_options)
#ifdef OPENSSL_MIN_PROTO_VERSION
SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
#endif
#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF
if(tls_ignore_missing_close_notify) {
init_options |= SSL_OP_IGNORE_UNEXPECTED_EOF;
}
#endif

DEBUG(D_tls) debug_printf("setting SSL CTX options: %016lx\n", init_options);
SSL_CTX_set_options(ctx, init_options);
{
Expand Down