Skip to content

Commit dd04c80

Browse files
committed
WL#15135 patch #5: Configure TLS in DB and MGM nodes
Part of WL#15135 Certificate Architecture In NDB data and management nodes, initialize TLS at startup time. ndbd and ndb_mgmd now take option --ndb-tls-search-path. Change-Id: I73e29c10af9d5366c53f86106ec82feac33c4bdf
1 parent 37144d5 commit dd04c80

File tree

10 files changed

+44
-12
lines changed

10 files changed

+44
-12
lines changed

storage/ndb/include/util/ndb_opts.h

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ OPT_EXTERN(const char *,opt_ndb_connectstring,=0);
4747
OPT_EXTERN(int, opt_connect_retry_delay,NONE);
4848
OPT_EXTERN(int, opt_connect_retries,NONE);
4949
OPT_EXTERN(const char *,opt_charsets_dir,=0);
50+
OPT_EXTERN(const char *,opt_tls_search_path,=NDB_TLS_SEARCH_PATH);
5051

5152
#ifndef NDEBUG
5253
OPT_EXTERN(const char *,opt_debug,= 0);
@@ -141,6 +142,12 @@ static constexpr struct my_option connect_retries =
141142
&opt_connect_retries, nullptr, nullptr, GET_INT, REQUIRED_ARG,
142143
12, -1, INT_MAX, nullptr, 0, nullptr};
143144

145+
static constexpr struct my_option tls_search_path =
146+
{ "ndb-tls-search-path", NDB_OPT_NOSHORT,
147+
"List of directories containing TLS keys and certificates",
148+
&opt_tls_search_path, nullptr, nullptr, GET_STR, REQUIRED_ARG,
149+
0, 0, 0, nullptr, 0, nullptr};
150+
144151
#ifndef NDEBUG
145152
static constexpr struct my_option debug =
146153
{ "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",

storage/ndb/src/common/util/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ ENDIF()
9595

9696
NDB_ADD_TEST(ndb_version-t version.cpp LIBS ndbgeneral)
9797

98+
SET_PROPERTY(SOURCE ndb_opts.cpp
99+
PROPERTY COMPILE_DEFINITIONS
100+
NDB_TLS_SEARCH_PATH="${WITH_NDB_TLS_SEARCH_PATH}")
101+
102+
98103
FOREACH(tests
99104
NdbPack
100105
mysql_utils_test

storage/ndb/src/kernel/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static struct my_option my_long_options[] =
7676
NdbStdOpt::ndb_nodeid,
7777
NdbStdOpt::connect_retry_delay, //used
7878
NdbStdOpt::connect_retries, // used
79+
NdbStdOpt::tls_search_path,
7980
NDB_STD_OPT_DEBUG
8081
{ "core-file", NDB_OPT_NOSHORT, "Write core on errors.",\
8182
&opt_core, nullptr, nullptr, GET_BOOL, NO_ARG,
@@ -265,7 +266,7 @@ real_main(int argc, char** argv)
265266
opt_ndb_connectstring, opt_ndb_nodeid, opt_bind_address,
266267
opt_no_start, opt_initial, opt_initialstart,
267268
opt_allocated_nodeid, opt_connect_retries, opt_connect_retry_delay,
268-
opt_logbuffer_size);
269+
opt_logbuffer_size, opt_tls_search_path);
269270
}
270271

271272
/**

storage/ndb/src/kernel/ndbd.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ ndbd_run(bool foreground, int report_fd,
10301030
const char* connect_str, int force_nodeid, const char* bind_address,
10311031
bool no_start, bool initial, bool initialstart,
10321032
unsigned allocated_nodeid, int connect_retries, int connect_delay,
1033-
size_t logbuffer_size)
1033+
size_t logbuffer_size, const char * tls_search_path)
10341034
{
10351035
log_memusage("ndbd_run");
10361036
LogBuffer* logBuf = new LogBuffer(logbuffer_size);
@@ -1169,6 +1169,7 @@ ndbd_run(bool foreground, int report_fd,
11691169

11701170
theConfig->setupConfiguration();
11711171

1172+
globalTransporterRegistry.init_tls(tls_search_path, NODE_TYPE_DB, true);
11721173

11731174
/**
11741175
Printout various information about the threads in the

storage/ndb/src/kernel/ndbd.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ndbd_run(bool foreground, int report_fd,
3333
const char* connect_str, int force_nodeid, const char* bind_address,
3434
bool no_start, bool initial, bool initialstart,
3535
unsigned allocated_nodeid, int connect_retries, int connect_delay,
36-
size_t logbuffer_size);
36+
size_t logbuffer_size, const char * tls_search_path);
3737

3838
enum NdbShutdownType {
3939
NST_Normal,

storage/ndb/src/mgmsrv/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ IF(WITHOUT_SERVER)
4141
RETURN()
4242
ENDIF()
4343

44+
ADD_COMPILE_DEFINITIONS(NDB_TLS_SEARCH_PATH="${WITH_NDB_TLS_SEARCH_PATH}")
45+
4446
# Define MYSQLCLUSTERDIR, the default location
4547
# of ndb_mgmd config files
4648
IF(NOT DEFINED DEFAULT_MYSQL_HOME)

storage/ndb/src/mgmsrv/MgmtSrvr.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ MgmtSrvr::MgmtSrvr(const MgmtOpts& opts) :
249249
m_local_config(NULL),
250250
_ownReference(0),
251251
m_config_manager(NULL),
252+
m_tls_search_path(opts.tls_search_path),
252253
m_need_restart(false),
253254
theFacade(NULL),
254255
_isStopThread(false),
@@ -391,22 +392,21 @@ MgmtSrvr::init()
391392

392393
assert(_ownNodeId);
393394

395+
theFacade= new TransporterFacade(0);
396+
if (theFacade == 0)
397+
{
398+
g_eventLogger->error("Could not create TransporterFacade.");
399+
DBUG_RETURN(false);
400+
}
401+
394402
DBUG_RETURN(true);
395403
}
396404

397-
398405
bool
399406
MgmtSrvr::start_transporter(const Config* config)
400407
{
401408
DBUG_ENTER("MgmtSrvr::start_transporter");
402409

403-
theFacade= new TransporterFacade(0);
404-
if (theFacade == 0)
405-
{
406-
g_eventLogger->error("Could not create TransporterFacade.");
407-
DBUG_RETURN(false);
408-
}
409-
410410
assert(_blockNumber == 0); // Blocknumber shouldn't been allocated yet
411411

412412
/*
@@ -572,6 +572,10 @@ MgmtSrvr::start()
572572
{
573573
DBUG_ENTER("MgmtSrvr::start");
574574

575+
/* Configure TLS */
576+
require(m_tls_search_path);
577+
theFacade->mgm_configure_tls(m_tls_search_path);
578+
575579
/* Start transporter */
576580
if(!start_transporter(m_local_config))
577581
{

storage/ndb/src/mgmsrv/MgmtSrvr.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ class MgmtSrvr : private ConfigSubscriber, public trp_client {
112112
int print_full_config;
113113
const char* configdir;
114114
int verbose;
115-
MgmtOpts() : configdir(MYSQLCLUSTERDIR) {}
116115
int reload;
117116
int initial;
118117
NodeBitmask nowait_nodes;
118+
const char* tls_search_path;
119+
120+
MgmtOpts() : configdir(MYSQLCLUSTERDIR),
121+
tls_search_path(NDB_TLS_SEARCH_PATH) {}
119122
};
120123

121124
MgmtSrvr(); // Not implemented
@@ -453,6 +456,8 @@ class MgmtSrvr : private ConfigSubscriber, public trp_client {
453456

454457
class ConfigManager* m_config_manager;
455458

459+
const char * m_tls_search_path { nullptr };
460+
456461
bool m_need_restart;
457462

458463
ndb_sockaddr m_connect_address[MAX_NODES];

storage/ndb/src/mgmsrv/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static struct my_option my_long_options[] =
113113
NdbStdOpt::ndb_nodeid,
114114
NdbStdOpt::mgmd_host,
115115
NdbStdOpt::connectstring,
116+
NdbStdOpt::tls_search_path,
116117
NDB_STD_OPT_DEBUG
117118
{ "config-file", 'f', "Specify cluster configuration file",
118119
&opts.config_filename, nullptr, nullptr, GET_STR, REQUIRED_ARG,
@@ -457,6 +458,8 @@ static int mgmd_main(int argc, char** argv)
457458
}
458459
}
459460

461+
opts.tls_search_path = opt_tls_search_path;
462+
460463
/* Setup use of event logger */
461464
g_eventLogger->setCategory(opt_logname);
462465

storage/ndb/src/ndbapi/TransporterFacade.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ class TransporterFacade :
7878
{
7979
configure_tls(searchPath, NODE_TYPE_API, primary);
8080
}
81+
void mgm_configure_tls(const char * searchPath)
82+
{
83+
configure_tls(searchPath, NODE_TYPE_MGM, true);
84+
}
8185

8286
/*
8387
(Re)configure the TransporterFacade

0 commit comments

Comments
 (0)