Skip to content

Commit 42ac528

Browse files
authored
Merge pull request #1352 from flavorjones/flavorjones-replace-mysql_ssl_set
use mysql_options if mysql_ssl_set isn't available (mysql client 8.3 support)
2 parents 79f78f9 + 1fb604f commit 42ac528

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ext/mysql2/client.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,12 +1435,31 @@ static VALUE set_charset_name(VALUE self, VALUE value) {
14351435
static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE capath, VALUE cipher) {
14361436
GET_CLIENT(self);
14371437

1438+
#ifdef HAVE_MYSQL_SSL_SET
14381439
mysql_ssl_set(wrapper->client,
14391440
NIL_P(key) ? NULL : StringValueCStr(key),
14401441
NIL_P(cert) ? NULL : StringValueCStr(cert),
14411442
NIL_P(ca) ? NULL : StringValueCStr(ca),
14421443
NIL_P(capath) ? NULL : StringValueCStr(capath),
14431444
NIL_P(cipher) ? NULL : StringValueCStr(cipher));
1445+
#else
1446+
/* mysql 8.3 does not provide mysql_ssl_set */
1447+
if (NIL_P(key)) {
1448+
mysql_options(wrapper->client, MYSQL_OPT_SSL_KEY, StringValueCStr(key));
1449+
}
1450+
if (NIL_P(cert)) {
1451+
mysql_options(wrapper->client, MYSQL_OPT_SSL_CERT, StringValueCStr(cert));
1452+
}
1453+
if (NIL_P(ca)) {
1454+
mysql_options(wrapper->client, MYSQL_OPT_SSL_CA, StringValueCStr(ca));
1455+
}
1456+
if (NIL_P(capath)) {
1457+
mysql_options(wrapper->client, MYSQL_OPT_SSL_CAPATH, StringValueCStr(capath));
1458+
}
1459+
if (NIL_P(cipher)) {
1460+
mysql_options(wrapper->client, MYSQL_OPT_SSL_CIPHER, StringValueCStr(cipher));
1461+
}
1462+
#endif
14441463

14451464
return self;
14461465
}

ext/mysql2/extconf.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ def add_ssl_defines(header)
164164
# to retain compatibility with the typedef in earlier MySQLs.
165165
have_type('my_bool', mysql_h)
166166

167+
# detect mysql functions
168+
have_func('mysql_ssl_set', mysql_h)
169+
167170
### Compiler flags to help catch errors
168171

169172
# This is our wishlist. We use whichever flags work on the host.

0 commit comments

Comments
 (0)