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;