-
Notifications
You must be signed in to change notification settings - Fork 552
adds tls sni support to mysql2 #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -504,26 +504,34 @@ static int opt_connect_attr_add_i(VALUE key, VALUE value, VALUE arg) | |||||
} | ||||||
#endif | ||||||
|
||||||
static VALUE rb_mysql_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags, VALUE conn_attrs) { | ||||||
static VALUE rb_mysql_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags, VALUE conn_attrs, VALUE tls_sni_name) { | ||||||
struct nogvl_connect_args args; | ||||||
time_t start_time, end_time, elapsed_time, connect_timeout; | ||||||
const char *sni_hostname; | ||||||
VALUE rv; | ||||||
GET_CLIENT(self); | ||||||
|
||||||
args.host = NIL_P(host) ? NULL : StringValueCStr(host); | ||||||
args.unix_socket = NIL_P(socket) ? NULL : StringValueCStr(socket); | ||||||
args.port = NIL_P(port) ? 0 : NUM2INT(port); | ||||||
args.user = NIL_P(user) ? NULL : StringValueCStr(user); | ||||||
args.passwd = NIL_P(pass) ? NULL : StringValueCStr(pass); | ||||||
args.db = NIL_P(database) ? NULL : StringValueCStr(database); | ||||||
args.mysql = wrapper->client; | ||||||
args.client_flag = NUM2ULONG(flags); | ||||||
args.host = NIL_P(host) ? NULL : StringValueCStr(host); | ||||||
args.unix_socket = NIL_P(socket) ? NULL : StringValueCStr(socket); | ||||||
args.port = NIL_P(port) ? 0 : NUM2INT(port); | ||||||
args.user = NIL_P(user) ? NULL : StringValueCStr(user); | ||||||
args.passwd = NIL_P(pass) ? NULL : StringValueCStr(pass); | ||||||
args.db = NIL_P(database) ? NULL : StringValueCStr(database); | ||||||
args.mysql = wrapper->client; | ||||||
args.client_flag = NUM2ULONG(flags); | ||||||
|
||||||
sni_hostname = NIL_P(tls_sni_name) ? NULL : StringValueCStr(tls_sni_name); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to refresh myself on this code to remember if this ought to go into the |
||||||
|
||||||
#ifdef CLIENT_CONNECT_ATTRS | ||||||
mysql_options(wrapper->client, MYSQL_OPT_CONNECT_ATTR_RESET, 0); | ||||||
rb_hash_foreach(conn_attrs, opt_connect_attr_add_i, (VALUE)wrapper); | ||||||
#endif | ||||||
|
||||||
if(sni_hostname != NULL) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Suggested change
|
||||||
/* Set the TLS SNI name if provided */ | ||||||
mysql_options(wrapper->client, MYSQL_OPT_TLS_SNI_SERVERNAME, sni_hostname); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found that this wasn't added until MySQL 8.1: However MySQL 8.0 is still in support window, so #ifdef protection is required. |
||||||
} | ||||||
|
||||||
if (wrapper->connect_timeout) | ||||||
time(&start_time); | ||||||
rv = (VALUE) rb_thread_call_without_gvl(nogvl_connect, &args, RUBY_UBF_IO, 0); | ||||||
|
@@ -1619,7 +1627,7 @@ void init_mysql2_client() { | |||||
rb_define_private_method(cMysql2Client, "ssl_mode=", rb_set_ssl_mode_option, 1); | ||||||
rb_define_private_method(cMysql2Client, "enable_cleartext_plugin=", set_enable_cleartext_plugin, 1); | ||||||
rb_define_private_method(cMysql2Client, "initialize_ext", initialize_ext, 0); | ||||||
rb_define_private_method(cMysql2Client, "connect", rb_mysql_connect, 8); | ||||||
rb_define_private_method(cMysql2Client, "connect", rb_mysql_connect, 9); | ||||||
rb_define_private_method(cMysql2Client, "_query", rb_mysql_query, 2); | ||||||
|
||||||
sym_id = ID2SYM(rb_intern("id")); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this spacing off by one or is that a GitHub display bug? (I'm reviewing on web)