From 4707ea4b48aff3474f4b15fc1e754326cb5c22d3 Mon Sep 17 00:00:00 2001 From: Noah Laptop Date: Sun, 14 Jun 2020 09:57:11 -0700 Subject: [PATCH] Refactored stop to avoid sending close_notify --- src/SSLClient.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SSLClient.cpp b/src/SSLClient.cpp index 997b67f..cbe3844 100644 --- a/src/SSLClient.cpp +++ b/src/SSLClient.cpp @@ -192,22 +192,22 @@ void SSLClient::flush() { /* see SSLClient.h */ void SSLClient::stop() { // tell the SSL connection to gracefully close - br_ssl_engine_close(&m_sslctx.eng); + // Disabled to prevent close_notify from hanging SSLClient + // br_ssl_engine_close(&m_sslctx.eng); // if the engine isn't closed, and the socket is still open - const auto state = br_ssl_engine_current_state(&m_sslctx.eng); - while (getWriteError() == SSL_OK - && m_is_connected - && state != BR_SSL_CLOSED + auto state = br_ssl_engine_current_state(&m_sslctx.eng); + if (state != BR_SSL_CLOSED && state != 0 - && m_run_until(BR_SSL_SENDAPP | BR_SSL_RECVAPP) == 0) { + && connected()) { /* * Discard any incoming application data. */ size_t len; - if (br_ssl_engine_recvapp_buf(&m_sslctx.eng, &len) != nullptr) { br_ssl_engine_recvapp_ack(&m_sslctx.eng, len); } + // run SSL to finish any existing transactions + flush(); } // close the ethernet socket get_arduino_client().flush();