Skip to content

Commit 8948014

Browse files
committed
WL#15154 post-push fixes
Change-Id: I97e56e84392a49d0510ac8a408db6df8556c76cb
1 parent 7b49448 commit 8948014

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

storage/ndb/src/common/mgmcommon/ConfigInfo.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <cstring>
2929
#include <optional>
3030
#include <time.h>
31+
#include "openssl/ssl.h"
3132

3233
#include "ConfigInfo.hpp"
3334
#include <mgmapi_config_parameters.h>
@@ -37,8 +38,9 @@
3738
#include <Bitmask.hpp>
3839
#include <ndb_opts.h>
3940
#include <ndb_version.h>
41+
#include "portlib/ndb_localtime.h"
42+
#include "portlib/ndb_openssl_version.h"
4043
#include "portlib/ndb_sockaddr.h"
41-
#include <portlib/ndb_localtime.h>
4244
#include <NdbTCP.h>
4345

4446
#define KEY_INTERNAL 0
@@ -49,6 +51,9 @@
4951
#define _STR_VALUE(x) #x
5052
#define STR_VALUE(x) _STR_VALUE(x)
5153

54+
static constexpr bool openssl_version_ok =
55+
(OPENSSL_VERSION_NUMBER >= NDB_TLS_MINIMUM_OPENSSL);
56+
5257
/****************************************************************************
5358
* Section names
5459
****************************************************************************/
@@ -3513,7 +3518,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
35133518

35143519
{
35153520
CFG_TCP_REQUIRE_TLS,
3516-
"RequireTls",
3521+
"RequireLinkTls",
35173522
"TCP",
35183523
"Use TLS authenticated secure connections for TCP transporter links",
35193524
ConfigInfo::CI_INTERNAL,
@@ -6358,7 +6363,11 @@ add_a_connection(Vector<ConfigInfo::ConfigRuleSection>&sections,
63586363
return ret == 0 ? true : false;
63596364
}
63606365
}
6361-
tmp->get("RequireTls", &reqTls1);
6366+
6367+
if(openssl_version_ok)
6368+
{
6369+
tmp->get("RequireTls", &reqTls1);
6370+
}
63626371

63636372
require(ctx.m_config->get("Node", nodeId2, &tmp));
63646373
tmp->get("HostName", &hostname2);
@@ -6386,7 +6395,11 @@ add_a_connection(Vector<ConfigInfo::ConfigRuleSection>&sections,
63866395
return ret == 0 ? true : false;
63876396
}
63886397
}
6389-
tmp->get("RequireTls", &reqTls2);
6398+
6399+
if(openssl_version_ok)
6400+
{
6401+
tmp->get("RequireTls", &reqTls2);
6402+
}
63906403

63916404
char buf[16];
63926405
s.m_sectionData= new Properties(true);
@@ -6415,7 +6428,7 @@ add_a_connection(Vector<ConfigInfo::ConfigRuleSection>&sections,
64156428
s.m_sectionData->put("TCP_MAXSEG_SIZE", 61440);
64166429
}
64176430

6418-
s.m_sectionData->put("RequireTls", reqTls1 | reqTls2);
6431+
s.m_sectionData->put("RequireLinkTls", reqTls1 | reqTls2);
64196432
}
64206433

64216434
sections.push_back(s);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,12 @@ Transporter::connect_client()
354354

355355
/** Socket Authentication */
356356
int auth = m_socket_client->authenticate(secureSocket);
357+
g_eventLogger->debug("Transporter client auth result: %d [%s]", auth,
358+
SocketAuthenticator::error(auth));
357359
if(auth < SocketAuthenticator::AuthOk)
358360
{
359361
DBUG_RETURN(false);
360362
}
361-
g_eventLogger->debug("Transporter client auth result: %d [%s]", auth,
362-
SocketAuthenticator::error(auth));
363363

364364
if(auth == SocketAuthTls::negotiate_tls_ok) // Initiate TLS
365365
{

storage/ndb/src/common/util/NodeCertificate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,12 @@ STACK_OF(X509) * Certificate::open(const char * path) {
671671
Certificate::read(certs, fp);
672672
fclose(fp);
673673
}
674+
675+
if(sk_X509_num(certs) == 0) {
676+
sk_X509_free(certs);
677+
certs = nullptr;
678+
}
679+
674680
return certs;
675681
}
676682

storage/ndb/src/common/util/SocketAuthenticator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int SocketAuthTls::client_authenticate(NdbSocket & sockfd)
109109
const bool tls_enabled = m_tls_keys->ctx();
110110

111111
// Write first line
112-
if(tls_required)
112+
if(tls_required && tls_enabled)
113113
s_output.println("ndbd TLS required");
114114
else if(tls_enabled)
115115
s_output.println("ndbd TLS enabled");

storage/ndb/src/kernel/ndbd.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@
5757
#include <LogBuffer.hpp>
5858
#include <OutputStream.hpp>
5959

60+
#include "util/ndb_openssl3_compat.h"
61+
6062
#define JAM_FILE_ID 484
6163

64+
static constexpr bool openssl_version_ok =
65+
(OPENSSL_VERSION_NUMBER >= NDB_TLS_MINIMUM_OPENSSL);
6266

6367
static void
6468
systemInfo(const Configuration & config, const LogLevel & logLevel)
@@ -1175,16 +1179,23 @@ ndbd_run(bool foreground, int report_fd,
11751179
globalEmulatorData.theConfiguration->getOwnConfigIterator();
11761180
require(p != nullptr);
11771181

1182+
if(openssl_version_ok)
11781183
{
1179-
Uint32 require_cert = 0;
1184+
Uint32 require_cert = 0, require_tls = 0;
11801185
ndb_mgm_get_int_parameter(p, CFG_NODE_REQUIRE_CERT, &require_cert);
1181-
if(require_cert && ! globalTransporterRegistry.hasTlsCert())
1186+
ndb_mgm_get_int_parameter(p, CFG_DB_REQUIRE_TLS, &require_tls);
1187+
if((require_cert || require_tls) &&
1188+
! globalTransporterRegistry.hasTlsCert())
11821189
{
11831190
g_eventLogger->error(
11841191
"Shutting down. This node does not have a valid TLS certificate.");
11851192
stop_async_log_func(log_threadvar, thread_args);
11861193
ndbd_exit(-1);
11871194
}
1195+
if(require_tls)
1196+
{
1197+
g_eventLogger->info("This node will require TLS for all connections.");
1198+
}
11881199
}
11891200

11901201
/**

0 commit comments

Comments
 (0)