diff --git a/source/common/ssl/connection_impl.cc b/source/common/ssl/connection_impl.cc index 2ba3f1647f667..a4d185ee00b00 100644 --- a/source/common/ssl/connection_impl.cc +++ b/source/common/ssl/connection_impl.cc @@ -119,7 +119,13 @@ Network::ConnectionImpl::PostIoAction ConnectionImpl::doHandshake() { } void ConnectionImpl::drainErrorQueue() { + bool saw_error = false; while (uint64_t err = ERR_get_error()) { + if (!saw_error) { + ctx_.stats().connection_error_.inc(); + saw_error = true; + } + conn_log_debug("SSL error: {}:{}:{}:{}", *this, err, ERR_lib_error_string(err), ERR_func_error_string(err), ERR_reason_error_string(err)); UNREFERENCED_PARAMETER(err); diff --git a/test/common/ssl/connection_impl_test.cc b/test/common/ssl/connection_impl_test.cc index 243020e365f74..22cd03e3c8910 100644 --- a/test/common/ssl/connection_impl_test.cc +++ b/test/common/ssl/connection_impl_test.cc @@ -248,6 +248,8 @@ TEST(SslConnectionImplTest, SslError) { })); dispatcher.run(Event::Dispatcher::RunType::Block); + + EXPECT_EQ(1UL, stats_store.counter("ssl.connection_error").value()); } class SslReadBufferLimitTest : public testing::Test { @@ -344,6 +346,8 @@ class SslReadBufferLimitTest : public testing::Test { } dispatcher.run(Event::Dispatcher::RunType::Block); + + EXPECT_EQ(0UL, stats_store.counter("ssl.connection_error").value()); } };