Merge branch 'v2.x-fast_forward_ssl' into v2.x-fast_forward_ssl2

pull/4062/head
René Cannaò 3 years ago
commit 9dde792c46

@ -0,0 +1,4 @@
Please note that upgrading `mariadb-connector-c` can require some changes
in `include/MySQL_Data_Stream.h` where we define `P_MARIADB_TLS` as a copy
of `MARIADB_TLS` . If `MARIADB_TLS` is changed, `P_MARIADB_TLS` must be
updated too.

@ -6,6 +6,21 @@
#include "MySQL_Protocol.h"
#ifndef uchar
typedef unsigned char uchar;
#endif
#include "ma_pvio.h"
// here we define P_MARIADB_TLS as a copy of MARIADB_TLS
// copied from ma_tls.h
// note that ma_pvio.h defines it as void
typedef struct P_st_ma_pvio_tls {
void *data;
MARIADB_PVIO *pvio;
void *ssl;
} P_MARIADB_TLS;
#define QUEUE_T_DEFAULT_SIZE 32768
#define MY_SSL_BUFFER 8192
@ -192,6 +207,26 @@ class MySQL_Data_Stream
myconn=mc;
myconn->statuses.myconnpoll_get++;
mc->myds=this;
// we handle encryption for backend
//
// we have a similar code in MySQL_Connection
// in case of ASYNC_CONNECT_SUCCESSFUL
encrypted = false;
if (sess != NULL && sess->session_fast_forward == true) {
if (myconn->mysql && myconn->ret_mysql) {
if (myconn->mysql->options.use_ssl == 1) {
encrypted = true;
if (ssl == NULL) {
// check the definition of P_MARIADB_TLS
P_MARIADB_TLS * matls = (P_MARIADB_TLS *)myconn->mysql->net.pvio->ctls;
ssl = (SSL *)matls->ssl;
rbio_ssl = BIO_new(BIO_s_mem());
wbio_ssl = BIO_new(BIO_s_mem());
SSL_set_bio(ssl, rbio_ssl, wbio_ssl);
}
}
}
}
}
// safe way to detach a MySQL Connection

@ -22,6 +22,7 @@ void ma_free_root(MA_MEM_ROOT *root, myf MyFLAGS);
void *ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size);
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
void * ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size)
{
size_t get_size;
@ -1113,6 +1114,26 @@ handler_again:
}
break;
case ASYNC_CONNECT_SUCCESSFUL:
if (mysql && ret_mysql) {
// we handle encryption for backend
//
// we have a similar code in MySQL_Data_Stream::attach_connection()
if (mysql->options.use_ssl == 1)
if (myds)
if (myds->sess != NULL)
if (myds->sess->session_fast_forward == true) {
myds->encrypted = true;
assert(myds->ssl==NULL);
if (myds->ssl == NULL) {
// check the definition of P_MARIADB_TLS
P_MARIADB_TLS * matls = (P_MARIADB_TLS *)mysql->net.pvio->ctls;
myds->ssl = (SSL *)matls->ssl;
myds->rbio_ssl = BIO_new(BIO_s_mem());
myds->wbio_ssl = BIO_new(BIO_s_mem());
SSL_set_bio(myds->ssl, myds->rbio_ssl, myds->wbio_ssl);
}
}
}
__sync_fetch_and_add(&MyHGM->status.server_connections_connected,1);
__sync_fetch_and_add(&parent->connect_OK,1);
options.client_flag = mysql->client_flag;

Loading…
Cancel
Save