Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: net/socket/ssl_client_socket_openssl.cc

Issue 655813003: Close SSLClientSocketOpenSSL cleanly if the transport was closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_openssl.cc
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc
index 04be9881e170f4ca6289ee17f15c1e99642c4ebf..953f3363806cd25c7977b318804154fa6c49eef5 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -1363,6 +1363,15 @@ int SSLClientSocketOpenSSL::DoPayloadRead() {
} else if (*next_result < 0) {
int err = SSL_get_error(ssl_, *next_result);
*next_result = MapOpenSSLError(err, err_tracer);
+
+ // Many servers do not reliably send a close_notify alert when shutting
+ // down a connection, and instead terminate the TCP connection. This is
+ // reported as ERR_CONNECTION_CLOSED. Because of this, map the unclean
+ // shutdown to a graceful EOF, instead of treating it as an error as it
+ // should be.
+ if (*next_result == ERR_CONNECTION_CLOSED)
+ *next_result = 0;
+
if (rv > 0 && *next_result == ERR_IO_PENDING) {
// If at least some data was read from SSL_read(), do not treat
// insufficient data as an error to return in the next call to
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698