From 4aaf111c5853f5d00594724ebbffffc5cd011931 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 15 Sep 2015 23:24:30 +0900 Subject: [PATCH] nghttpx: Fix assertion failure on TLS handshake --- src/shrpx_connection.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/shrpx_connection.cc b/src/shrpx_connection.cc index aee91b8d..1a197e45 100644 --- a/src/shrpx_connection.cc +++ b/src/shrpx_connection.cc @@ -146,7 +146,14 @@ int shrpx_bio_write(BIO *b, const char *buf, int len) { if (conn->tls.initial_handshake_done) { // After handshake finished, send |buf| of length |len| to the // socket directly. - assert(wbuf.rleft() == 0); + + // Only when TLS session was prematurely ended before server sent + // all handshake message, this condition is true. This could be + // alert from SSL_shutdown(). Since connection is already down, + // just return error. + if (wbuf.rleft()) { + return -1; + } auto nwrite = conn->write_clear(buf, len); if (nwrite < 0) { return -1;