Patch ssl.patch for MySQLi related Bug #76809
Patch version 2018-08-31 16:15 UTC
Return to Bug #76809 |
Download this patch
Patch Revisions:
Developer: fabio.souto@miniclip.com
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index f1e805ce41..008b208c9f 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -62,15 +62,17 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
MY_MYSQL *mysql = NULL;
MYSQLI_RESOURCE *mysqli_resource = NULL;
zval *object = getThis();
- char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
+ char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL,
+ *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL,
+ *ssl_cipher = NULL;
int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
- zend_bool persistent = FALSE;
+ zend_bool persistent = FALSE, ssl = FALSE;
long port = 0, flags = 0;
uint hash_len;
char *hash_key = NULL;
zend_bool new_connection = FALSE;
zend_rsrc_list_entry *le;
- mysqli_plist_entry *plist = NULL;
+ mysqli_plist_entry *plist = NULL;
zend_bool self_alloced = 0;
@@ -187,6 +189,18 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
MyG(num_active_persistent)++;
goto end;
} else {
+#ifdef MYSQLI_USE_MYSQLND
+ if (mysql->mysql->data->net->data->ssl) {
+ /* copy over pre-existing ssl settings so we can reuse them when reconnecting */
+ ssl = TRUE;
+
+ ssl_key = my_estrdup(mysql->mysql->data->net->data->options.ssl_key);
+ ssl_cert = my_estrdup(mysql->mysql->data->net->data->options.ssl_cert);
+ ssl_ca = my_estrdup(mysql->mysql->data->net->data->options.ssl_ca);
+ ssl_capath = my_estrdup(mysql->mysql->data->net->data->options.ssl_capath);
+ ssl_cipher = my_estrdup(mysql->mysql->data->net->data->options.ssl_cipher);
+ }
+#endif
mysqli_close(mysql->mysql, MYSQLI_CLOSE_IMPLICIT);
mysql->mysql = NULL;
}
@@ -241,6 +255,10 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port, socket, flags) == NULL)
#else
+ if (ssl) {
+ /* if we're here, this means previous conn was ssl, repopulate settings */
+ mysql_ssl_set(mysql->mysql, ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher);
+ }
if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname, dbname_len,
port, socket, flags, MYSQLND_CLIENT_KNOWS_RSET_COPY_DATA TSRMLS_CC) == NULL)
#endif
|