Skip to content

Commit fc4d88b

Browse files
author
Bryan Call
committed
Merge pull request apache#37 from Edge/TS-3667
TS-3667: SSL Handshake read does not correctly handle EOF and error cases.
2 parents 33317b9 + 03f870f commit fc4d88b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-*- coding: utf-8 -*-
22
Changes with Apache Traffic Server 6.0.0
33

4+
*) [TS-3667] Make SSL Handhake read correctly handle EOF and error cases.
5+
46
*) [TS-3560] Make proxy.config.http.slow.log.threshold overridable
57

68
*) [TS-3378] SpdyRequest used after free()

iocore/net/SSLNetVConnection.cc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,6 @@ SSLNetVConnection::read_raw_data()
347347
if (r <= 0) {
348348
if (r == -EAGAIN || r == -ENOTCONN) {
349349
NET_INCREMENT_DYN_STAT(net_calls_to_read_nodata_stat);
350-
return r;
351-
}
352-
353-
if (!r || r == -ECONNRESET) {
354-
return r;
355350
}
356351
return r;
357352
}
@@ -960,7 +955,22 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err)
960955
if (BIO_eof(SSL_get_rbio(this->ssl))) { // No more data in the buffer
961956
// Read from socket to fill in the BIO buffer with the
962957
// raw handshake data before calling the ssl accept calls.
963-
this->read_raw_data();
958+
int retval = this->read_raw_data();
959+
if (retval < 0) {
960+
if (retval == -EAGAIN) {
961+
// No data at the moment, hang tight
962+
SSLDebugVC(this, "SSL handshake: EAGAIN");
963+
return SSL_HANDSHAKE_WANT_READ;
964+
} else {
965+
// An error, make us go away
966+
SSLDebugVC(this, "SSL handshake error: read_retval=%d", retval);
967+
return EVENT_ERROR;
968+
}
969+
} else if (retval == 0) {
970+
// EOF, go away, we stopped in the handshake
971+
SSLDebugVC(this, "SSL handshake error: EOF");
972+
return EVENT_ERROR;
973+
}
964974
}
965975

966976
ssl_error_t ssl_error = SSLAccept(ssl);

0 commit comments

Comments
 (0)