Skip to content

Commit 84d0d25

Browse files
committed
BUG#23336595 MYSQL X PLUGIN - ADD LINK TO DOCUMENTATION ON HOW TO CONFIGURE SSL
Description: The requested talks about putting a link to X Plugin which describes how to setup SSL. Solution: Added new trace, which reference the MySQL documentation: "For more information, please see the Using Secure Connections" " with X Plugin section in the MySQL documentation" Made additional cleanup in the trace messages. RB: 13578 Reviewed-by: Grzegorz Szwarc <[email protected]>
1 parent 93e7ca4 commit 84d0d25

File tree

6 files changed

+54
-58
lines changed

6 files changed

+54
-58
lines changed

rapid/plugin/x/ngs/include/ngs_common/connection_vio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Ssl_context
139139
{
140140
public:
141141
Ssl_context();
142-
void setup(const char* tls_version,
142+
bool setup(const char* tls_version,
143143
const char* ssl_key,
144144
const char* ssl_ca,
145145
const char* ssl_capath,

rapid/plugin/x/ngs/ngs_common/connection_vio.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ Ssl_context::Ssl_context()
291291
{
292292
}
293293

294-
void Ssl_context::setup(const char* tls_version,
295-
const char* ssl_key,
296-
const char* ssl_ca,
297-
const char* ssl_capath,
298-
const char* ssl_cert,
299-
const char* ssl_cipher,
300-
const char* ssl_crl,
301-
const char* ssl_crlpath)
294+
bool Ssl_context::setup(const char *tls_version,
295+
const char *ssl_key,
296+
const char *ssl_ca,
297+
const char *ssl_capath,
298+
const char *ssl_cert,
299+
const char *ssl_cipher,
300+
const char *ssl_crl,
301+
const char *ssl_crlpath)
302302
{
303303
enum_ssl_init_error error = SSL_INITERR_NOERROR;
304304

@@ -313,10 +313,12 @@ void Ssl_context::setup(const char* tls_version,
313313
if (NULL == m_ssl_acceptor)
314314
{
315315
log_warning("Failed at SSL configuration: \"%s\"", sslGetErrString(error));
316-
return;
316+
return false;
317317
}
318318

319319
m_options.reset(new Options_context_ssl(m_ssl_acceptor));
320+
321+
return true;
320322
}
321323

322324

rapid/plugin/x/src/xpl_server.cc

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,22 @@ static xpl::Ssl_config choose_ssl_config(const bool mysqld_have_ssl,
525525
const xpl::Ssl_config & mysqlx_ssl)
526526
{
527527
if (!mysqlx_ssl.is_configured() && mysqld_have_ssl)
528+
{
529+
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL,
530+
"Using SSL configuration from MySQL Server");
531+
528532
return mysqld_ssl;
533+
}
529534

530535
if (mysqlx_ssl.is_configured())
536+
{
537+
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL,
538+
"Using SSL configuration from Mysqlx Plugin");
531539
return mysqlx_ssl;
540+
}
541+
542+
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL,
543+
"Neither MySQL Server nor Mysqlx Plugin has valid SSL configuration");
532544

533545
return xpl::Ssl_config();
534546
}
@@ -581,37 +593,31 @@ bool xpl::Server::on_net_startup()
581593
instance->start_verify_server_state_timer();
582594

583595
ngs::Ssl_context_unique_ptr ssl_ctx(new ngs::Ssl_context());
584-
try
585-
{
586-
ssl_config = choose_ssl_config(mysqld_have_ssl,
587-
ssl_config,
588-
xpl::Plugin_system_variables::ssl_config);
589-
590-
#ifdef HAVE_YASSL
591-
// YaSSL doesn't support CRL according to vio
592-
const char *crl = NULL;
593-
const char *crlpath = NULL;
594-
#else
595-
const char *crl = ssl_config.ssl_crl;
596-
const char *crlpath = ssl_config.ssl_crlpath;
597-
#endif
598-
ssl_ctx->setup(tls_version,
599-
ssl_config.ssl_key,
600-
ssl_config.ssl_ca,
601-
ssl_config.ssl_capath,
602-
ssl_config.ssl_cert,
603-
ssl_config.ssl_cipher,
604-
crl, crlpath);
605596

606-
#if !defined(HAVE_YASSL)
607-
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL, "Using OpenSSL for connections");
608-
#else
609-
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL, "Using YaSSL for connections");
610-
#endif
597+
ssl_config = choose_ssl_config(mysqld_have_ssl,
598+
ssl_config,
599+
xpl::Plugin_system_variables::ssl_config);
600+
601+
// YaSSL doesn't support CRL according to vio
602+
const char *crl = IS_YASSL_OR_OPENSSL(NULL, ssl_config.ssl_crl);
603+
const char *crlpath = IS_YASSL_OR_OPENSSL(NULL, ssl_config.ssl_crlpath);
604+
605+
const bool ssl_setup_result = ssl_ctx->setup(tls_version, ssl_config.ssl_key,
606+
ssl_config.ssl_ca,
607+
ssl_config.ssl_capath,
608+
ssl_config.ssl_cert,
609+
ssl_config.ssl_cipher,
610+
crl, crlpath);
611+
612+
if (ssl_setup_result)
613+
{
614+
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL,
615+
"Using " IS_YASSL_OR_OPENSSL("YaSSL", "OpenSSL") " for TLS connections");
611616
}
612-
catch (std::exception &e)
617+
else
613618
{
614-
throw ngs::Error_code(ER_X_SERVICE_ERROR, std::string("SSL context setup failed: \"") + e.what() + std::string("\""));
619+
my_plugin_log_message(&xpl::plugin_handle, MY_INFORMATION_LEVEL,
620+
"For more information, please see the Using Secure Connections with X Plugin section in the MySQL documentation.");
615621
}
616622

617623
if (instance->server().prepare(boost::move(ssl_ctx), skip_networking, skip_name_resolve, true))

rapid/plugin/x/src/xpl_server.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,10 @@ void Server::update_status_variable(xpl::Common_status_variables &status_variabl
278278

279279
} // namespace xpl
280280

281+
#ifdef HAVE_YASSL
282+
#define IS_YASSL_OR_OPENSSL(Y, O) Y
283+
#else // HAVE_YASSL
284+
#define IS_YASSL_OR_OPENSSL(Y, O) O
285+
#endif // HAVE_YASSL
286+
281287
#endif // _XPL_SERVER_H_

rapid/plugin/x/src/xpl_system_variables.cc

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ void Plugin_system_variables::setup_system_variable_from_env_or_compile_opt(char
7676

7777

7878
Ssl_config::Ssl_config()
79-
: ssl_key(NULL), ssl_ca(NULL), ssl_capath(NULL), ssl_cert(NULL), ssl_cipher(NULL), ssl_crl(NULL), ssl_crlpath(NULL), m_null_char(0)
79+
: ssl_key(NULL), ssl_ca(NULL), ssl_capath(NULL), ssl_cert(NULL), ssl_cipher(NULL),
80+
ssl_crl(NULL), ssl_crlpath(NULL), m_null_char(0)
8081
{
8182
}
8283

@@ -91,24 +92,6 @@ bool Ssl_config::is_configured() const
9192
has_value(ssl_crlpath);
9293
}
9394

94-
/*void Ssl_config::set_not_null_value()
95-
{
96-
if (!has_value(ssl_key))
97-
ssl_key = &m_null_char;
98-
if (!has_value(ssl_ca))
99-
ssl_ca = &m_null_char;
100-
if (!has_value(ssl_capath))
101-
ssl_capath = &m_null_char;
102-
if (!has_value(ssl_cert))
103-
ssl_cert = &m_null_char;
104-
if (!has_value(ssl_cipher))
105-
ssl_cipher = &m_null_char;
106-
if (!has_value(ssl_crl))
107-
ssl_crl = &m_null_char;
108-
if (!has_value(ssl_crlpath))
109-
ssl_crlpath = &m_null_char;
110-
}*/
111-
11295
bool Ssl_config::has_value(const char *ptr) const
11396
{
11497
return ptr && *ptr;

rapid/plugin/x/src/xpl_system_variables.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct Ssl_config
3939
Ssl_config();
4040

4141
bool is_configured() const;
42-
// void set_not_null_value();
4342

4443
char *ssl_key;
4544
char *ssl_ca;

0 commit comments

Comments
 (0)