Skip to content

Commit 4b1e94b

Browse files
committed
Since we use TLS and not SSL functions and structures were renamed
from SSL to TLS
1 parent f68b89b commit 4b1e94b

18 files changed

+329
-1182
lines changed

include/ma_common.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ struct st_mysql_options_extension {
4949
const char *proc_info,
5050
unsigned int proc_info_length);
5151
MARIADB_DB_DRIVER *db_driver;
52-
char *ssl_fp; /* finger print of server certificate */
53-
char *ssl_fp_list; /* white list of finger prints */
54-
char *ssl_pw; /* password for encrypted certificates */
52+
char *tls_fp; /* finger print of server certificate */
53+
char *tls_fp_list; /* white list of finger prints */
54+
char *tls_pw; /* password for encrypted certificates */
5555
my_bool multi_command; /* indicates if client wants to send multiple
5656
commands in one packet */
5757
char *url; /* for connection handler we need to save URL for reconnect */
58-
unsigned int ssl_cipher_strength;
58+
unsigned int tls_cipher_strength;
59+
char *tls_version;
5960
my_bool read_only;
6061
char *connection_handler;
6162
my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);

include/ma_pvio.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#define cio_defined
44

55
#ifdef HAVE_SSL
6-
#include <ma_ssl.h>
6+
#include <ma_tls.h>
77
#else
8-
#define MARIADB_SSL void
8+
#define MARIADB_TLS void
99
#endif
1010

1111
#define PVIO_SET_ERROR if (pvio->set_error) \
@@ -78,7 +78,7 @@ struct st_ma_pvio {
7878
enum enum_pvio_type type;
7979
int timeout[3];
8080
int ssl_type; /* todo: change to enum (ssl plugins) */
81-
MARIADB_SSL *cssl;
81+
MARIADB_TLS *ctls;
8282
MYSQL *mysql;
8383
struct mysql_async_context *async_context; /* For non-blocking API */
8484
PVIO_METHODS *methods;

include/ma_ssl.h include/ma_tls.h

+49-49
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#ifndef _ma_ssl_h_
2-
#define _ma_ssl_h_
1+
#ifndef _ma_tls_h_
2+
#define _ma_tls_h_
33

4-
enum enum_pvio_ssl_type {
4+
enum enum_pvio_tls_type {
55
SSL_TYPE_DEFAULT=0,
66
#ifdef _WIN32
77
SSL_TYPE_SCHANNEL,
@@ -10,11 +10,11 @@ enum enum_pvio_ssl_type {
1010
SSL_TYPE_GNUTLS
1111
};
1212

13-
typedef struct st_ma_pvio_ssl {
13+
typedef struct st_ma_pvio_tls {
1414
void *data;
1515
MARIADB_PVIO *pvio;
1616
void *ssl;
17-
} MARIADB_SSL;
17+
} MARIADB_TLS;
1818

1919
struct st_ssl_version {
2020
unsigned int iversion;
@@ -23,7 +23,7 @@ struct st_ssl_version {
2323

2424
/* Function prototypes */
2525

26-
/* ma_ssl_start
26+
/* ma_tls_start
2727
initializes the ssl library
2828
Parameter:
2929
errmsg pointer to error message buffer
@@ -32,17 +32,17 @@ struct st_ssl_version {
3232
0 success
3333
1 if an error occured
3434
Notes:
35-
On success the global variable ma_ssl_initialized will be set to 1
35+
On success the global variable ma_tls_initialized will be set to 1
3636
*/
37-
int ma_ssl_start(char *errmsg, size_t errmsg_len);
37+
int ma_tls_start(char *errmsg, size_t errmsg_len);
3838

39-
/* ma_ssl_end
39+
/* ma_tls_end
4040
unloads/deinitializes ssl library and unsets global variable
41-
ma_ssl_initialized
41+
ma_tls_initialized
4242
*/
43-
void ma_ssl_end(void);
43+
void ma_tls_end(void);
4444

45-
/* ma_ssl_init
45+
/* ma_tls_init
4646
creates a new SSL structure for a SSL connection and loads
4747
client certificates
4848
@@ -51,106 +51,106 @@ void ma_ssl_end(void);
5151
Returns:
5252
void * a pointer to internal SSL structure
5353
*/
54-
void * ma_ssl_init(MYSQL *mysql);
54+
void * ma_tls_init(MYSQL *mysql);
5555

56-
/* ma_ssl_connect
56+
/* ma_tls_connect
5757
performs SSL handshake
5858
Parameters:
59-
MARIADB_SSL MariaDB SSL container
59+
MARIADB_TLS MariaDB SSL container
6060
Returns:
6161
0 success
6262
1 error
6363
*/
64-
my_bool ma_ssl_connect(MARIADB_SSL *cssl);
64+
my_bool ma_tls_connect(MARIADB_TLS *ctls);
6565

66-
/* ma_ssl_read
66+
/* ma_tls_read
6767
reads up to length bytes from socket
6868
Parameters:
69-
cssl MariaDB SSL container
69+
ctls MariaDB SSL container
7070
buffer read buffer
7171
length buffer length
7272
Returns:
7373
0-n bytes read
7474
-1 if an error occured
7575
*/
76-
size_t ma_ssl_read(MARIADB_SSL *cssl, const uchar* buffer, size_t length);
76+
size_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length);
7777

78-
/* ma_ssl_write
78+
/* ma_tls_write
7979
write buffer to socket
8080
Parameters:
81-
cssl MariaDB SSL container
81+
ctls MariaDB SSL container
8282
buffer write buffer
8383
length buffer length
8484
Returns:
8585
0-n bytes written
8686
-1 if an error occured
8787
*/
88-
size_t ma_ssl_write(MARIADB_SSL *cssl, const uchar* buffer, size_t length);
88+
size_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length);
8989

90-
/* ma_ssl_close
90+
/* ma_tls_close
9191
closes SSL connection and frees SSL structure which was previously
92-
created by ma_ssl_init call
92+
created by ma_tls_init call
9393
Parameters:
94-
MARIADB_SSL MariaDB SSL container
94+
MARIADB_TLS MariaDB SSL container
9595
Returns:
9696
0 success
9797
1 error
9898
*/
99-
my_bool ma_ssl_close(MARIADB_SSL *cssl);
99+
my_bool ma_tls_close(MARIADB_TLS *ctls);
100100

101-
/* ma_ssl_verify_server_cert
101+
/* ma_tls_verify_server_cert
102102
validation check of server certificate
103103
Parameter:
104-
MARIADB_SSL MariaDB SSL container
104+
MARIADB_TLS MariaDB SSL container
105105
Returns:
106106
ß success
107107
1 error
108108
*/
109-
int ma_ssl_verify_server_cert(MARIADB_SSL *cssl);
109+
int ma_tls_verify_server_cert(MARIADB_TLS *ctls);
110110

111-
/* ma_ssl_get_cipher
111+
/* ma_tls_get_cipher
112112
returns cipher for current ssl connection
113113
Parameter:
114-
MARIADB_SSL MariaDB SSL container
114+
MARIADB_TLS MariaDB SSL container
115115
Returns:
116116
cipher in use or
117117
NULL on error
118118
*/
119-
const char *ma_ssl_get_cipher(MARIADB_SSL *ssl);
119+
const char *ma_tls_get_cipher(MARIADB_TLS *ssl);
120120

121-
/* ma_ssl_get_finger_print
121+
/* ma_tls_get_finger_print
122122
returns SHA1 finger print of server certificate
123123
Parameter:
124-
MARIADB_SSL MariaDB SSL container
124+
MARIADB_TLS MariaDB SSL container
125125
fp buffer for fingerprint
126126
fp_len buffer length
127127
Returns:
128128
actual size of finger print
129129
*/
130-
unsigned int ma_ssl_get_finger_print(MARIADB_SSL *cssl, unsigned char *fp, unsigned int fp_len);
130+
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsigned int fp_len);
131131

132-
/* ma_ssl_get_protocol_version
132+
/* ma_tls_get_protocol_version
133133
returns protocol version in use
134134
Parameter:
135-
MARIADB_SSL MariaDB SSL container
135+
MARIADB_TLS MariaDB SSL container
136136
version pointer to ssl version info
137137
Returns:
138138
0 success
139139
1 error
140140
*/
141-
my_bool ma_ssl_get_protocol_version(MARIADB_SSL *cssl, struct st_ssl_version *version);
141+
my_bool ma_tls_get_protocol_version(MARIADB_TLS *ctls, struct st_ssl_version *version);
142142

143143
/* Function prototypes */
144-
MARIADB_SSL *ma_pvio_ssl_init(MYSQL *mysql);
145-
my_bool ma_pvio_ssl_connect(MARIADB_SSL *cssl);
146-
size_t ma_pvio_ssl_read(MARIADB_SSL *cssl, const uchar *buffer, size_t length);
147-
size_t ma_pvio_ssl_write(MARIADB_SSL *cssl, const uchar *buffer, size_t length);
148-
my_bool ma_pvio_ssl_close(MARIADB_SSL *cssl);
149-
int ma_pvio_ssl_verify_server_cert(MARIADB_SSL *cssl);
150-
const char *ma_pvio_ssl_cipher(MARIADB_SSL *cssl);
151-
my_bool ma_pvio_ssl_check_fp(MARIADB_SSL *cssl, const char *fp, const char *fp_list);
144+
MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql);
145+
my_bool ma_pvio_tls_connect(MARIADB_TLS *ctls);
146+
size_t ma_pvio_tls_read(MARIADB_TLS *ctls, const uchar *buffer, size_t length);
147+
size_t ma_pvio_tls_write(MARIADB_TLS *ctls, const uchar *buffer, size_t length);
148+
my_bool ma_pvio_tls_close(MARIADB_TLS *ctls);
149+
int ma_pvio_tls_verify_server_cert(MARIADB_TLS *ctls);
150+
const char *ma_pvio_tls_cipher(MARIADB_TLS *ctls);
151+
my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list);
152152
my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio);
153-
my_bool ma_pvio_ssl_get_protocol_version(MARIADB_SSL *cssl, struct st_ssl_version *version);
154-
void ma_pvio_ssl_end();
153+
my_bool ma_pvio_tls_get_protocol_version(MARIADB_TLS *ctls, struct st_ssl_version *version);
154+
void ma_pvio_tls_end();
155155

156-
#endif /* _ma_ssl_h_ */
156+
#endif /* _ma_tls_h_ */

include/mariadb_async.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extern ssize_t my_send_async(MARIADB_PVIO *pvio,
2929
extern my_bool my_io_wait_async(struct mysql_async_context *b,
3030
enum enum_pvio_io_event event, int timeout);
3131
#ifdef HAVE_SSL
32-
extern int my_ssl_read_async(struct mysql_async_context *b, MARIADB_SSL *ssl,
32+
extern int my_ssl_read_async(struct mysql_async_context *b, MARIADB_TLS *tls,
3333
void *buf, int size);
34-
extern int my_ssl_write_async(struct mysql_async_context *b, MARIADB_SSL *ssl,
34+
extern int my_ssl_write_async(struct mysql_async_context *b, MARIADB_TLS *tls,
3535
const void *buf, int size);
3636
#endif
3737

include/mysql.h

+11-8
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,16 @@ extern unsigned int mariadb_deinitialize_ssl;
214214
MYSQL_OPT_NONBLOCK,
215215
/* MariaDB Connector/C specific */
216216
MYSQL_DATABASE_DRIVER=7000,
217-
MARIADB_OPT_SSL_FP, /* single finger print for server certificate verification */
218-
MARIADB_OPT_SSL_FP_LIST, /* finger print white list for server certificate verification */
219-
MARIADB_OPT_SSL_PASSPHRASE, /* passphrase for encrypted certificates */
217+
MARIADB_OPT_SSL_FP, /* deprecated, use MARIADB_OPT_TLS_PEER_FP instead */
218+
MARIADB_OPT_SSL_FP_LIST, /* deprecated, use MARIADB_OPT_TLS_PEER_FP_LIST instead */
219+
MARIADB_OPT_TLS_PASSPHRASE, /* passphrase for encrypted certificates */
220+
MARIADB_OPT_TLS_CIPHER_STRENGTH,
221+
MARIADB_OPT_TLS_VERSION,
222+
MARIADB_OPT_TLS_PEER_FP, /* single finger print for server certificate verification */
223+
MARIADB_OPT_TLS_PEER_FP_LIST, /* finger print white list for server certificate verification */
220224
MARIADB_OPT_CONNECTION_READ_ONLY,
221225
MYSQL_OPT_CONNECT_ATTRS, /* for mysql_get_optionv */
222226
MARIADB_OPT_USERDATA,
223-
MARIADB_OPT_SSL_CIPHER_STRENGTH,
224227
MARIADB_OPT_CONNECTION_HANDLER,
225228
MARIADB_OPT_PORT,
226229
MARIADB_OPT_UNIXSOCKET,
@@ -259,14 +262,14 @@ extern unsigned int mariadb_deinitialize_ssl;
259262
MARIADB_CONNECTION_SOCKET,
260263
MARIADB_CONNECTION_SQLSTATE,
261264
MARIADB_CONNECTION_SSL_CIPHER,
262-
MARIADB_SSL_LIBRARY,
263-
MARIADB_CONNECTION_SSL_VERSION,
264-
MARIADB_CONNECTION_SSL_VERSION_ID,
265+
MARIADB_TLS_LIBRARY,
266+
MARIADB_CONNECTION_TLS_VERSION,
267+
MARIADB_CONNECTION_TLS_VERSION_ID,
265268
MARIADB_CONNECTION_TYPE,
266269
MARIADB_CONNECTION_UNIX_SOCKET,
267270
MARIADB_CONNECTION_USER,
268271
MARIADB_MAX_ALLOWED_PACKET,
269-
MARIADB_NET_BUFFER_LENGTH
272+
MARIADB_NET_BUFFER_LENGTH,
270273
};
271274

272275
enum mysql_status { MYSQL_STATUS_READY,

libmariadb/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ ma_errmsg.c
251251
mariadb_lib.c
252252
ma_list.c
253253
ma_pvio.c
254-
ma_ssl.c
254+
ma_tls.c
255255
ma_alloc.c
256256
ma_compress.c
257257
ma_init.c

0 commit comments

Comments
 (0)