Skip to content

Commit

Permalink
Merge pull request #1352 from flavorjones/flavorjones-replace-mysql_s…
Browse files Browse the repository at this point in the history
…sl_set

use mysql_options if mysql_ssl_set isn't available (mysql client 8.3 support)
  • Loading branch information
tenderlove authored Feb 8, 2024
2 parents 79f78f9 + 1fb604f commit 42ac528
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,12 +1435,31 @@ static VALUE set_charset_name(VALUE self, VALUE value) {
static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE capath, VALUE cipher) {
GET_CLIENT(self);

#ifdef HAVE_MYSQL_SSL_SET
mysql_ssl_set(wrapper->client,
NIL_P(key) ? NULL : StringValueCStr(key),
NIL_P(cert) ? NULL : StringValueCStr(cert),
NIL_P(ca) ? NULL : StringValueCStr(ca),
NIL_P(capath) ? NULL : StringValueCStr(capath),
NIL_P(cipher) ? NULL : StringValueCStr(cipher));
#else
/* mysql 8.3 does not provide mysql_ssl_set */
if (NIL_P(key)) {
mysql_options(wrapper->client, MYSQL_OPT_SSL_KEY, StringValueCStr(key));
}
if (NIL_P(cert)) {
mysql_options(wrapper->client, MYSQL_OPT_SSL_CERT, StringValueCStr(cert));
}
if (NIL_P(ca)) {
mysql_options(wrapper->client, MYSQL_OPT_SSL_CA, StringValueCStr(ca));
}
if (NIL_P(capath)) {
mysql_options(wrapper->client, MYSQL_OPT_SSL_CAPATH, StringValueCStr(capath));
}
if (NIL_P(cipher)) {
mysql_options(wrapper->client, MYSQL_OPT_SSL_CIPHER, StringValueCStr(cipher));
}
#endif

return self;
}
Expand Down
3 changes: 3 additions & 0 deletions ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def add_ssl_defines(header)
# to retain compatibility with the typedef in earlier MySQLs.
have_type('my_bool', mysql_h)

# detect mysql functions
have_func('mysql_ssl_set', mysql_h)

### Compiler flags to help catch errors

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

0 comments on commit 42ac528

Please sign in to comment.