Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 229292d

Browse files
jkedgarHerman Lee
authored andcommitted
Export connection's SSL/TLS version
Summary: Right now MySQL doesn't export the SSL/TLS version that was used for connecting. This provides a function that can be called by the client to get that information. Reviewed By: lth Differential Revision: D34912346
1 parent b61c227 commit 229292d

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎include/mysql.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ MYSQL *STDCALL mysql_init(MYSQL *mysql);
476476
bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
477477
const char *ca, const char *capath,
478478
const char *cipher);
479+
const char* STDCALL mysql_get_ssl_version(MYSQL *mysql);
479480
const char *STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
480481
bool STDCALL mysql_get_ssl_session_reused(MYSQL *mysql);
481482
void *STDCALL mysql_get_ssl_session_data(MYSQL *mysql, unsigned int n_ticket,

‎include/mysql.h.pp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@
676676
bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
677677
const char *ca, const char *capath,
678678
const char *cipher);
679+
const char * mysql_get_ssl_version(MYSQL *mysql);
679680
const char * mysql_get_ssl_cipher(MYSQL *mysql);
680681
bool mysql_get_ssl_session_reused(MYSQL *mysql);
681682
void * mysql_get_ssl_session_data(MYSQL *mysql, unsigned int n_ticket,

‎libmysql/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ SET(CLIENT_API_FUNCTIONS
157157
net_flush
158158
net_clear
159159
my_net_write
160+
mysql_get_ssl_version
160161

161162
CACHE INTERNAL "Functions exported by client API"
162163
)

‎sql-common/client.cc‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3624,6 +3624,22 @@ static void mysql_ssl_free(MYSQL *mysql) {
36243624
mysql->connector_fd = nullptr;
36253625
}
36263626

3627+
/*
3628+
Return the TLS/SSL version (if any) used for current
3629+
connection to the server.
3630+
3631+
SYNOPSYS
3632+
mysql_get_ssl_version()
3633+
mysql pointer to the mysql connection
3634+
*/
3635+
3636+
const char* STDCALL mysql_get_ssl_version(MYSQL *mysql MY_ATTRIBUTE((unused))) {
3637+
DBUG_TRACE;
3638+
if (mysql->net.vio && mysql->net.vio->ssl_arg)
3639+
return SSL_get_version((SSL *)mysql->net.vio->ssl_arg);
3640+
return nullptr;
3641+
}
3642+
36273643
/*
36283644
Return the SSL cipher (if any) used for current
36293645
connection to the server.

0 commit comments

Comments
 (0)