Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
585c096a
Commit
585c096a
authored
Aug 30, 2023
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: unify client's setting of ssl options
parent
03094bbc
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
122 deletions
+37
-122
client/mysql.cc
client/mysql.cc
+1
-12
client/mysqladmin.cc
client/mysqladmin.cc
+3
-12
client/mysqlbinlog.cc
client/mysqlbinlog.cc
+1
-12
client/mysqlcheck.c
client/mysqlcheck.c
+1
-12
client/mysqldump.cc
client/mysqldump.cc
+1
-12
client/mysqlimport.c
client/mysqlimport.c
+1
-12
client/mysqlshow.c
client/mysqlshow.c
+1
-12
client/mysqlslap.c
client/mysqlslap.c
+1
-12
client/mysqltest.cc
client/mysqltest.cc
+11
-26
include/sslopt-vars.h
include/sslopt-vars.h
+16
-0
No files found.
client/mysql.cc
View file @
585c096a
...
@@ -1496,18 +1496,7 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
...
@@ -1496,18 +1496,7 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
{
{
if
(
opt_secure_auth
)
if
(
opt_secure_auth
)
mysql_options
(
mysql
,
MYSQL_SECURE_AUTH
,
(
char
*
)
&
opt_secure_auth
);
mysql_options
(
mysql
,
MYSQL_SECURE_AUTH
,
(
char
*
)
&
opt_secure_auth
);
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
SET_SSL_OPTS
(
mysql
);
if
(
opt_use_ssl
&&
opt_protocol
<=
MYSQL_PROTOCOL_SOCKET
)
{
mysql_ssl_set
(
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
if
(
opt_plugin_dir
&&
*
opt_plugin_dir
)
if
(
opt_plugin_dir
&&
*
opt_plugin_dir
)
...
...
client/mysqladmin.cc
View file @
585c096a
...
@@ -370,18 +370,9 @@ int main(int argc,char *argv[])
...
@@ -370,18 +370,9 @@ int main(int argc,char *argv[])
uint
tmp
=
opt_connect_timeout
;
uint
tmp
=
opt_connect_timeout
;
mysql_options
(
&
mysql
,
MYSQL_OPT_CONNECT_TIMEOUT
,
(
char
*
)
&
tmp
);
mysql_options
(
&
mysql
,
MYSQL_OPT_CONNECT_TIMEOUT
,
(
char
*
)
&
tmp
);
}
}
#ifdef HAVE_OPENSSL
if
(
opt_use_ssl
)
SET_SSL_OPTS
(
&
mysql
);
{
mysql_ssl_set
(
&
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
&
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
&
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
&
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
if
(
!
strcmp
(
default_charset
,
MYSQL_AUTODETECT_CHARSET_NAME
))
if
(
!
strcmp
(
default_charset
,
MYSQL_AUTODETECT_CHARSET_NAME
))
...
...
client/mysqlbinlog.cc
View file @
585c096a
...
@@ -2351,18 +2351,7 @@ static Exit_status safe_connect()
...
@@ -2351,18 +2351,7 @@ static Exit_status safe_connect()
return
ERROR_STOP
;
return
ERROR_STOP
;
}
}
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
mysql
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
/*HAVE_OPENSSL*/
if
(
opt_plugindir
&&
*
opt_plugindir
)
if
(
opt_plugindir
&&
*
opt_plugindir
)
mysql_options
(
mysql
,
MYSQL_PLUGIN_DIR
,
opt_plugindir
);
mysql_options
(
mysql
,
MYSQL_PLUGIN_DIR
,
opt_plugindir
);
...
...
client/mysqlcheck.c
View file @
585c096a
...
@@ -1124,18 +1124,7 @@ static int dbConnect(char *host, char *user, char *passwd)
...
@@ -1124,18 +1124,7 @@ static int dbConnect(char *host, char *user, char *passwd)
mysql_init
(
&
mysql_connection
);
mysql_init
(
&
mysql_connection
);
if
(
opt_compress
)
if
(
opt_compress
)
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_COMPRESS
,
NullS
);
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
&
mysql_connection
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
&
mysql_connection
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
&
mysql_connection
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
&
mysql_connection
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
...
...
client/mysqldump.cc
View file @
585c096a
...
@@ -1992,18 +1992,7 @@ static MYSQL* connect_to_db(char *host, char *user,char *passwd)
...
@@ -1992,18 +1992,7 @@ static MYSQL* connect_to_db(char *host, char *user,char *passwd)
MYSQL
*
con
=
mysql_init
(
NULL
);
MYSQL
*
con
=
mysql_init
(
NULL
);
if
(
opt_compress
)
if
(
opt_compress
)
mysql_options
(
con
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
con
,
MYSQL_OPT_COMPRESS
,
NullS
);
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
con
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
con
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
con
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
con
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
con
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
con
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
con
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
con
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
con
,
MYSQL_SET_CHARSET_NAME
,
default_charset
);
mysql_options
(
con
,
MYSQL_SET_CHARSET_NAME
,
default_charset
);
...
...
client/mysqlimport.c
View file @
585c096a
...
@@ -461,18 +461,7 @@ static MYSQL *db_connect(char *host, char *database,
...
@@ -461,18 +461,7 @@ static MYSQL *db_connect(char *host, char *database,
if
(
opt_local_file
)
if
(
opt_local_file
)
mysql_options
(
mysql
,
MYSQL_OPT_LOCAL_INFILE
,
mysql_options
(
mysql
,
MYSQL_OPT_LOCAL_INFILE
,
(
char
*
)
&
opt_local_file
);
(
char
*
)
&
opt_local_file
);
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
mysql
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
...
...
client/mysqlshow.c
View file @
585c096a
...
@@ -120,18 +120,7 @@ int main(int argc, char **argv)
...
@@ -120,18 +120,7 @@ int main(int argc, char **argv)
mysql_init
(
&
mysql
);
mysql_init
(
&
mysql
);
if
(
opt_compress
)
if
(
opt_compress
)
mysql_options
(
&
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
&
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
&
mysql
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
&
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
&
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
&
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
&
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
&
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
...
...
client/mysqlslap.c
View file @
585c096a
...
@@ -295,18 +295,7 @@ void set_mysql_connect_options(MYSQL *mysql)
...
@@ -295,18 +295,7 @@ void set_mysql_connect_options(MYSQL *mysql)
{
{
if
(
opt_compress
)
if
(
opt_compress
)
mysql_options
(
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
#ifdef HAVE_OPENSSL
SET_SSL_OPTS
(
mysql
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
}
mysql_options
(
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
(
char
*
)
&
opt_ssl_verify_server_cert
);
#endif
if
(
opt_protocol
)
if
(
opt_protocol
)
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
mysql
,
MYSQL_OPT_PROTOCOL
,(
char
*
)
&
opt_protocol
);
mysql_options
(
mysql
,
MYSQL_SET_CHARSET_NAME
,
default_charset
);
mysql_options
(
mysql
,
MYSQL_SET_CHARSET_NAME
,
default_charset
);
...
...
client/mysqltest.cc
View file @
585c096a
...
@@ -290,6 +290,13 @@ DYNAMIC_ARRAY q_lines;
...
@@ -290,6 +290,13 @@ DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h"
#include "sslopt-vars.h"
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
static
void
set_ssl_opts
(
MYSQL
*
mysql
,
my_bool
opt_use_ssl
,
char
*
opt_ssl_cipher
)
{
SET_SSL_OPTS
(
mysql
);
}
#endif
struct
Parser
struct
Parser
{
{
int
read_lines
,
current_line
;
int
read_lines
,
current_line
;
...
@@ -6166,19 +6173,9 @@ void do_connect(struct st_command *command)
...
@@ -6166,19 +6173,9 @@ void do_connect(struct st_command *command)
opt_charsets_dir
);
opt_charsets_dir
);
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if
(
con_ssl
==
USE_SSL_IF_POSSIBLE
&&
opt_use_ssl
)
set_ssl_opts
(
con_slot
->
mysql
,
con_ssl
==
USE_SSL_FORBIDDEN
?
0
:
con_ssl
=
USE_SSL_REQUIRED
;
con_ssl
==
USE_SSL_REQUIRED
?
1
:
opt_use_ssl
,
ssl_cipher
?
ssl_cipher
:
opt_ssl_cipher
);
if
(
con_ssl
==
USE_SSL_REQUIRED
)
{
mysql_ssl_set
(
con_slot
->
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
ssl_cipher
?
ssl_cipher
:
opt_ssl_cipher
);
mysql_options
(
con_slot
->
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
con_slot
->
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
con_slot
->
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
mysql_options
(
con_slot
->
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
&
opt_ssl_verify_server_cert
);
}
#endif
#endif
if
(
protocol
)
if
(
protocol
)
...
@@ -10116,19 +10113,7 @@ int main(int argc, char **argv)
...
@@ -10116,19 +10113,7 @@ int main(int argc, char **argv)
if
(
opt_plugin_dir
&&
*
opt_plugin_dir
)
if
(
opt_plugin_dir
&&
*
opt_plugin_dir
)
mysql_options
(
con
->
mysql
,
MYSQL_PLUGIN_DIR
,
opt_plugin_dir
);
mysql_options
(
con
->
mysql
,
MYSQL_PLUGIN_DIR
,
opt_plugin_dir
);
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
SET_SSL_OPTS
(
con
->
mysql
);
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
con
->
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
mysql_options
(
con
->
mysql
,
MYSQL_OPT_SSL_CRL
,
opt_ssl_crl
);
mysql_options
(
con
->
mysql
,
MYSQL_OPT_SSL_CRLPATH
,
opt_ssl_crlpath
);
mysql_options
(
con
->
mysql
,
MARIADB_OPT_TLS_VERSION
,
opt_tls_version
);
mysql_options
(
con
->
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
&
opt_ssl_verify_server_cert
);
}
#endif
if
(
!
(
con
->
name
=
my_strdup
(
PSI_NOT_INSTRUMENTED
,
"default"
,
MYF
(
MY_WME
))))
if
(
!
(
con
->
name
=
my_strdup
(
PSI_NOT_INSTRUMENTED
,
"default"
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
die
(
"Out of memory"
);
...
...
include/sslopt-vars.h
View file @
585c096a
...
@@ -33,6 +33,22 @@ SSL_STATIC char *opt_ssl_crlpath = 0;
...
@@ -33,6 +33,22 @@ SSL_STATIC char *opt_ssl_crlpath = 0;
SSL_STATIC
char
*
opt_tls_version
=
0
;
SSL_STATIC
char
*
opt_tls_version
=
0
;
#ifdef MYSQL_CLIENT
#ifdef MYSQL_CLIENT
SSL_STATIC
my_bool
opt_ssl_verify_server_cert
=
0
;
SSL_STATIC
my_bool
opt_ssl_verify_server_cert
=
0
;
#define SET_SSL_OPTS(M) \
do { \
if (opt_use_ssl) \
{ \
mysql_ssl_set((M), opt_ssl_key, opt_ssl_cert, opt_ssl_ca, \
opt_ssl_capath, opt_ssl_cipher); \
mysql_options((M), MYSQL_OPT_SSL_CRL, opt_ssl_crl); \
mysql_options((M), MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); \
mysql_options((M), MARIADB_OPT_TLS_VERSION, opt_tls_version); \
} \
mysql_options((M),MYSQL_OPT_SSL_VERIFY_SERVER_CERT, \
&opt_ssl_verify_server_cert); \
} while(0)
#endif
#endif
#else
#define SET_SSL_OPTS(M) do { } while(0)
#endif
#endif
#endif
/* SSLOPT_VARS_INCLUDED */
#endif
/* SSLOPT_VARS_INCLUDED */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment