From 4e31b9bbb943e4389549171be3b8079229f5ba7c Mon Sep 17 00:00:00 2001 From: Mike McDonald Date: Mon, 20 Jan 2014 11:08:33 -0500 Subject: [PATCH] Revert "Modified TLS code to handle disconnects a little cleaner." This reverts commit c273a4ac5e7cca51fc7dbdc10a683227bb164120. --- include/freerdp/crypto/tls.h | 1 - libfreerdp/crypto/tls.c | 31 ++++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/include/freerdp/crypto/tls.h b/include/freerdp/crypto/tls.h index 2135c752f..09ff7a3a0 100644 --- a/include/freerdp/crypto/tls.h +++ b/include/freerdp/crypto/tls.h @@ -43,7 +43,6 @@ struct rdp_tls void* tsg; int sockfd; SSL_CTX* ctx; - int disconnected; BYTE* PublicKey; BIO_METHOD* methods; DWORD PublicKeyLength; diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index dd82618d8..b6c11790c 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -364,22 +364,7 @@ BOOL tls_disconnect(rdpTls* tls) return FALSE; if (tls->ssl) - { - if (tls->disconnected) - { - /** - * In cases where the underlying socket has become disconnected, - * there is no need to send a "close notify" shutdown alert. In - * fact, attempting to do so can cause a crash in SSL_shutdown. - * - * The following code disables sending the "close notify". - */ - - SSL_set_quiet_shutdown(tls->ssl, 1); - } - SSL_shutdown(tls->ssl); - } return TRUE; } @@ -427,7 +412,6 @@ int tls_read(rdpTls* tls, BYTE* data, int length) else { tls_print_error("SSL_read", tls->ssl, status); - tls->disconnected = 1; status = -1; } break; @@ -439,6 +423,13 @@ int tls_read(rdpTls* tls, BYTE* data, int length) } } + /* No need to send "close notify" shutdown alert to peer. In + fact, some circumstances will cause SSL_shutdown to crash. */ + if (status == -1) + { + SSL_set_shutdown(tls->ssl, SSL_SENT_SHUTDOWN); + } + return status; } @@ -479,7 +470,6 @@ int tls_write(rdpTls* tls, BYTE* data, int length) else { tls_print_error("SSL_write", tls->ssl, status); - tls->disconnected = 1; status = -1; } break; @@ -491,6 +481,13 @@ int tls_write(rdpTls* tls, BYTE* data, int length) } } + /* No need to send "close notify" shutdown alert to peer. In + fact, some circumstances will cause SSL_shutdown to crash. */ + if (status == -1) + { + SSL_set_shutdown(tls->ssl, SSL_SENT_SHUTDOWN); + } + return status; }