Skip to content

Commit 55fae71

Browse files
committed
WL#15154 patch #5 Establish TLS
Post push fix. Add missing calls to close to avoid socket leaks. Had Change-Id: I4bfc2209e6f976aa5642a3c7fa6f12395e9fdc60 Change-Id: Idbe81f0f70bbf827b673d5842b65a74f79a455f9
1 parent 94f69e9 commit 55fae71

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

storage/ndb/src/common/transporter/Transporter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define DEBUG_FPRINTF(a)
4848
#endif
4949

50-
//#define DEBUG_MULTI_TRP 1
50+
// #define DEBUG_MULTI_TRP 1
5151

5252
#ifdef DEBUG_MULTI_TRP
5353
#define DEB_MULTI_TRP(arglist) \
@@ -324,15 +324,18 @@ bool Transporter::connect_client() {
324324
struct ssl_st *ssl = NdbSocket::get_client_ssl(ctx);
325325
if (ssl == nullptr) {
326326
tls_error(TlsKeyError::no_local_cert);
327+
secureSocket.close();
327328
DBUG_RETURN(false);
328329
}
329330
if (!secureSocket.associate(ssl)) {
330331
tls_error(TlsKeyError::openssl_error);
331332
NdbSocket::free_ssl(ssl);
333+
secureSocket.close();
332334
DBUG_RETURN(false);
333335
}
334336
if (!secureSocket.do_tls_handshake()) {
335337
tls_error(TlsKeyError::authentication_failure);
338+
// secureSocket closed by do_tls_handshake
336339
DBUG_RETURN(false);
337340
}
338341

@@ -341,6 +344,7 @@ bool Transporter::connect_client() {
341344
TlsKeyManager::check_server_host_auth(secureSocket, remoteHostName);
342345
if (auth) {
343346
tls_error(auth);
347+
secureSocket.close();
344348
DBUG_RETURN(false);
345349
}
346350
}

storage/ndb/src/common/transporter/TransporterRegistry.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,22 @@ SocketServer::Session *TransporterService::newSession(
129129
struct ssl_ctx_st *ctx = m_transporter_registry->m_tls_keys.ctx();
130130
struct ssl_st *ssl = NdbSocket::get_server_ssl(ctx);
131131
if (ssl == nullptr) {
132+
DEBUG_FPRINTF((stderr,
133+
"Failed to authenticate new session, no server "
134+
"cerificate\n"));
135+
secureSocket.close_with_reset();
132136
DBUG_RETURN(nullptr);
133137
}
134138
if (!secureSocket.associate(ssl)) {
139+
DEBUG_FPRINTF((stderr,
140+
"Failed to authenticate new session, fail to "
141+
"associate certificate with connection\n"));
135142
NdbSocket::free_ssl(ssl);
143+
secureSocket.close_with_reset();
136144
DBUG_RETURN(nullptr);
137145
}
138146
if (!secureSocket.do_tls_handshake()) {
147+
// secureSocket closed by do_tls_handshake
139148
DBUG_RETURN(nullptr);
140149
}
141150
}

0 commit comments

Comments
 (0)